creating matrix out of certain data of a matrix
2 views (last 30 days)
Show older comments
Hi guys. M = 1511x1 % this is a matrix with different values.
I want to take the data which are greater than 2 from M and put them in another matrix T.
So far I have this code, but it doesn't work :(
x=1;
T=[x:1];
while x<1512
if size(M(x,1))>2
k = M(x,1);
T(x,:) = k;
end;
x=x+1;
end;
Plz help.
0 Comments
Accepted Answer
Star Strider
on 15 Apr 2014
I suggest:
% Create Data:
M = rand(1151,1)*10;
% Create Output Vector ‘T’
T = M(M > 2);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!