How do I combine results of a loop in an array?

2 ビュー (過去 30 日間)
Mayla
Mayla 2023 年 9 月 7 日
コメント済み: Harald 2023 年 9 月 7 日
I am trying to create an array like [1 2 2 3 3 3 4 4 4 4] if n=4 for any n
My first idea was
for m = 1:n
x = [1:m]
x(:)=m
y=[x]
end
But I don't know how I could add all the results to one array.
I am completly new to MATLAB and coding (my second day) so I would be happy if somebody could help me and explain it very easily :)
  4 件のコメント
Mayla
Mayla 2023 年 9 月 7 日
Thanks :) I got it! Do you have any tipps for practicing and improving with matlab?
Harald
Harald 2023 年 9 月 7 日
Hi Mayla,
As a first step, you may find the free MATLAB Onramp helpful.
Best wishes,
Harald

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

回答 (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