How to fill an array with the elements of a for loop?

12 ビュー (過去 30 日間)
Juan Velasquez
Juan Velasquez 2021 年 7 月 8 日
コメント済み: Juan Velasquez 2021 年 7 月 8 日
Hi, i have this code, and i want to put all of the elements from the loop inside an array, can anyone help me?
ll=[1 2 3 4 5]
for c= 1:1:length(ll)
element=ll(c)+3
end
%%result==>> ll= 4 5 6 7 8
  2 件のコメント
Geoff Hayes
Geoff Hayes 2021 年 7 月 8 日
Juan - do you need to use a loop? What happens if you just do
element = ll + 3;
?
Juan Velasquez
Juan Velasquez 2021 年 7 月 8 日
yeah, because i am practicing with the for loop.

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

採用された回答

Soniya Jain
Soniya Jain 2021 年 7 月 8 日
編集済み: Soniya Jain 2021 年 7 月 8 日
Use element(c) instead

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by