フィルターのクリア

Add rows of a vector in a for loop

3 ビュー (過去 30 日間)
Collin Poesch
Collin Poesch 2018 年 6 月 4 日
編集済み: Collin Poesch 2018 年 6 月 5 日
How can I get it so that the matrix "okay" is put into a larger matrix that will hold all outputs of "okay"?
for i=1:8
for n=1:cornerpoints
dist = sqrt ((twothirdspoint(i,1) - twothirdspoint(n,1))^2 +(twothirdspoint(i,2) - twothirdspoint(n,2))^2);
if (dist < 50) && (dist~=0)
Badx = twothirdspoint(n,1);
Bady = twothirdspoint(n,2);
otherbadx = twothirdspoint(i,1);
otherbady = twothirdspoint(i,2);
badmatrix(1,:) = [Badx,Bady];
otherbadmatrix(1,:) = [otherbadx, otherbady];
okay = [badmatrix;otherbadmatrix];
disp(okay);
end
end
end

採用された回答

Paridhi Yadav
Paridhi Yadav 2018 年 6 月 5 日
編集済み: Paridhi Yadav 2018 年 6 月 5 日
Hey, so you can first declare a large matrix of (8*cornerpoints*2) x 2 and declare a variable k and then every time inside the loop you can store the value of okay in larger matrix like this
largeMatrix(k:k+1,:) = okay;
And increment k by 2 every time.
  1 件のコメント
Collin Poesch
Collin Poesch 2018 年 6 月 5 日
編集済み: Collin Poesch 2018 年 6 月 5 日
Could you be a little more specific? Where inside the loop would I put that? Thanks:) nevermind I got it, thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by