- #1
- 1
- 0
So, I'm doing a loop through 612 rows of data, each row having 2592 numbers. If the number I'm looking at is NOT equal to NaN, I want to do a calculation using a different array. This way, if the element in sfc_data is not a number, the number in lat_matrix in that same column is ignored, and if the element in sfc_data IS a number, the matching number from lat_matrix is added to the weights array. However when I do the following loop, it's doing the calculation regardless of whether the number in the first array equals NaN.
for i = 0,611 do begin
for j = 0, 2591 do begin
if sfc_data[j,i] ne 'NaN' then weights = weights + lat_matrix[j,0]
endfor
endfor
The loop is doing the full number of calculations as if none of the numbers in sfc_data are NaN (there are definitely many NaN's in sfc_data). So how do I check if sfc_data[j,i] is equal to the string NaN and isn't actually a number?
for i = 0,611 do begin
for j = 0, 2591 do begin
if sfc_data[j,i] ne 'NaN' then weights = weights + lat_matrix[j,0]
endfor
endfor
The loop is doing the full number of calculations as if none of the numbers in sfc_data are NaN (there are definitely many NaN's in sfc_data). So how do I check if sfc_data[j,i] is equal to the string NaN and isn't actually a number?