I have a matrix 6×37 stability_cond with 1 and twos
[a,b]=find(stability_cond==1); idx1=[a,b]; [c,d]=find(stability_cond==2); idx2=[c,d];
The code to find the position of 1 and 2 in stability_cond.
I want to use the position to fix stability_class using conditions in the variable WindSp using the code below
for s=1:138 for k=idx1(1:end,:) for l=idx1(:,1:end) if (WindSp(k(s,1),l(s,1))<2) stability_class(k(s,1),l(s,1))=1; elseif(WindSp(k(s,1),l(s,1)==2)|WindSp(k(s,1),l(s,1))<3) stability_class(k(s,1),l(s,1))=2; elseif(WindSp(k(s,1),l(s,1))==3|WindSp(k(s),l(s))<5) %#ok<*OR2>
stability_class(k(s,1),l(s,1))=3; elseif((WindSp(k(s,1),l(s,1))==5)|(WindSp(k(s,1),l(s,1))<6)) stability_class(k(s,1),l(s,1))=4; else stability_class(k(s,1),l(s,1))=5; end end endend
I keep getting the error: Index exceeds matrix dimensions.
Best Answer