Determining criteria from two different arrays

1 view (last 30 days)
d = an array of 3 columns, u_sign an array of (:,:,1,:) (from a nc file so it seems to retain a 4D structure)
I am trying to find it where for the values of d(:,1) it searches whether the u_sign value at d(:,2) + 2 is greater than the u_sign value at d(:,2). I can't seem to get it to work. It says the index exceeds matrix dimensions but I can't work out why. Thanks for any answers :)
B = zeros(length(data),2);
C = zeros(length(data),2);
for k = 1:length(d);
u_sign = u_sign(:,:,1,d(k,1));
%(getting the array into the right shape):
u_sign = rot90(u_sign);
u_sign = [(u_sign(:,(73:144))) (u_sign(:,(1:72)))];
u_sign = u_sign((44:67),:);
%the test: u_sign(r,c) > u_sign(r+2,c) (below):
if u_sign(d(k,2),d(k,3)) > u_sign((d(k,2))+2,d(k,3)),...
B(k,:) = [d(k,2),d(k,3)];
else C = 0;
end
end
[ii jj] = find(B > 0);
new_data = [ii jj]
clear B C
  2 Comments
Geoff Hayes
Geoff Hayes on 25 Nov 2014
Oliver - at which line is the error being generated? Please also include the dimensions of your data, d, and u_sign matrices. As well, are the value of d valid so that they can be used as indices within u_sign?
Star Strider
Star Strider on 25 Nov 2014
What is the maximum value of ‘d(:,2)’ and ‘d(:,3)’?
What is the row size of ‘u_sign’?

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!