Can't read the variable value in the below mentioned "for" loop

Kindly help me with this error

Can’t read “x(1)”:no such variable
While executing
“expr $X($j) -$X($j)”
(“for” body line 2 )
Invoked from within
“for {set j 1} {$j<= $val(nn)} {incr j} {
set dx [expr $X($j) -$X($j)]
set dy [expr $Y($j) -$X($j)]
puts stdout $dx
puts stdout $dy
(file “ns1.tcl” line 74)

Without seeing your assignment to $X we won’t be able to help. Off-hand, I’d think the error is telling you that your $X array does not have a value at index 1.