extract data from matrix and store into a new matirx
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kingsley
am 6 Feb. 2018
Kommentiert: Star Strider
am 6 Feb. 2018
I want to extract data of row 6 and the last row from the test matrix. Here is my code:
test=[1 2;13 12; 3 0; 4 0; 5 3; 30 10; 2 10; 30 1;10 4; 50 9; 60 7]
data=zeros(2,2);
for j=1:2
for i=1:6
i=1+5;
data(i,j)=test(i,j)
end
end
data
the correct answer should be
data=[30 10 ; 60 7]
however, it comes up with something wrong.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 6 Feb. 2018
You do not need the loop.
This works:
data = test([6 end],:);
data =
30 10
60 7
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!