- #1
Halsey
- 3
- 0
Hi all-
I have a question regarding using the find function as opposed to if statements in finding values in a 4D array. These are climate variables, such as temperature (in Kelvin). Missing values are represented as 10^15, and I want to change them to NaN which plots much nicer. I have the following code so far:
for i = 1:288 %all longitudes
for j = 1:144 %all latitudes
for k = 1:42 %all heights
for l = 1:8 %all times
if temp(i,j,k,l) > 1000
temp(i,j,k,l) =0/0;
end
end
end
end
end
and it is doing what I want, but I fear that it is not very efficient because i have 11 climate variables total to do this for, and the if conditionals waste a lot of time. i have used the find function on 1D and 2D arrays, but I do not know how it works, if at all, on 4D arrays. Any help would be great! Thanks in advance.
I have a question regarding using the find function as opposed to if statements in finding values in a 4D array. These are climate variables, such as temperature (in Kelvin). Missing values are represented as 10^15, and I want to change them to NaN which plots much nicer. I have the following code so far:
for i = 1:288 %all longitudes
for j = 1:144 %all latitudes
for k = 1:42 %all heights
for l = 1:8 %all times
if temp(i,j,k,l) > 1000
temp(i,j,k,l) =0/0;
end
end
end
end
end
and it is doing what I want, but I fear that it is not very efficient because i have 11 climate variables total to do this for, and the if conditionals waste a lot of time. i have used the find function on 1D and 2D arrays, but I do not know how it works, if at all, on 4D arrays. Any help would be great! Thanks in advance.