フィルターのクリア

convert for loop's answers into a vector

3 ビュー (過去 30 日間)
다영 박
다영 박 2021 年 9 月 2 日
編集済み: 다영 박 2021 年 9 月 2 日
aR2=rand(1,30)
for i=1:30
maR2= mean(aR2)
end
How can i convert for loop's answers into a vector?

採用された回答

KSSV
KSSV 2021 年 9 月 2 日
mean(aR2) is a scalar value, why you want to store it into a vector?
Are you looking for saving values in a loop into a array? Then consider below example.
n = 30 ;
A = rand(1,n) ;
iwant = zeros(1,n) ;
for i = 1:n
iwant(i) = rand*A(i)
end
The above can alos be achieved without loop.
  1 件のコメント
다영 박
다영 박 2021 年 9 月 2 日
編集済み: 다영 박 2021 年 9 月 2 日
I know it's a scalar but, tutorial is wanted me to make it a vector.
so, thank you for the code!

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

その他の回答 (1 件)

Chunru
Chunru 2021 年 9 月 2 日
The following is not really a conversion and more a correction;
aR2=rand(1,30);
maR2= mean(aR2)
maR2 = 0.4798

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by