How to store each for loop array values in avariable?

1 回表示 (過去 30 日間)
Vellan
Vellan 2019 年 12 月 4 日
コメント済み: Vellan 2019 年 12 月 4 日
Hello,
I would like to store the array values that I got using a for loop in a single variable. This was the code that I used.
function ret=poly_prod(P1,P2)
n=poly_row(P1)
m=poly_row(P2)
a=size(n)
b=size(m)
for n=1:b(2)
ret=P1*P2(n)
end
end
I got an answer like this,
ret =
3 3 -21 -45
ret =
-1 -1 7 15
ret =
2 2 -14 -30
R =
2 2 -14 -30
I am expecting the output to be like R = 3 3 -21 -45 -1 -1 7 15 2 2 -14 -30
Thank you.

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 4 日
ret=[];
for n=1:b(2)
ret=[ret P1*P2(n)]
end
  1 件のコメント
Vellan
Vellan 2019 年 12 月 4 日
Thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by