M and T are 1024*366 matrix want to make a separate matrix that follow some condition?

1 view (last 30 days)
M and T are 1024*366 matrix want to make a separate matrix that follow some condition
A=[];
nnn=1;
for i=1:1023
nn=1;
for j=1:965
if (T(j,i)>500 && T(j,i)<600)
A(nn,nnn)=M(j,i);
A(nn,nnn+1)=T(j,i);
end
end
nnn=nnn+4;
end
This error How can I solve?
Attempted to access T(1,967); index out of bounds because size(T)=[1024,966].

Accepted Answer

Walter Roberson
Walter Roberson on 25 Aug 2013
If M and T are 1024 * 366 then why is your "j" loop running to 965? And since your "i" loop is running to 1023 and it is the first dimension that is as large as 1024, then why are you using "i" to index the second dimension of the matrix instead of the first ?

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!