Determining criteria from two different arrays

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

Geoff Hayes
Geoff Hayes 2014년 11월 25일
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?
What is the maximum value of ‘d(:,2)’ and ‘d(:,3)’?
What is the row size of ‘u_sign’?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2014년 11월 25일

댓글:

2014년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by