フィルターのクリア

extract data from matrix and store into a new matirx

2 ビュー (過去 30 日間)
kingsley
kingsley 2018 年 2 月 6 日
コメント済み: Star Strider 2018 年 2 月 6 日
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.

採用された回答

Star Strider
Star Strider 2018 年 2 月 6 日
You do not need the loop.
This works:
data = test([6 end],:);
data =
30 10
60 7
  4 件のコメント
kingsley
kingsley 2018 年 2 月 6 日
thank you so much ! it works
Star Strider
Star Strider 2018 年 2 月 6 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by