Move selected column from a matrix to another
Show older comments
Hello Matlab community,
I am a beginner in Matlab.
I have a matrix M, I would like to select from this matrix the columns which have a value between Xmin and Xmax in the lign 310 and also value between Ymin and Ymax in the lign 620. Then copied the columns selected in a new matrix. Below, it's the code I tried, however the answer is that all the colums are copied into the matrix x.
Xmin = 429500;
Xmax = 431500;
Ymin = 5907000;
Ymax = 5910000;
n = 7000;
dt = 620;
x = zeros(dt,n);
y = zeros(dt,n);
for in=1:n
if Xmin>= M(310,in)<= Xmax & Ymin>=M(620,in)<= Ymax;
x(:,in) = M(:,in);
else
x(:,in) = x(:,in);
end
end
Can someone help me please?
Regards
Jonathan
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!