フィルターのクリア

Basic For Loop problem

1 回表示 (過去 30 日間)
Muhammad Ahsan
Muhammad Ahsan 2021 年 1 月 30 日
コメント済み: Walter Roberson 2021 年 1 月 31 日
It is not very difficult code but I don't know why I am getting error. The value of the k should be printed like 1, 1, 1, 2, 2, 2, 3, 3, 3, ....... 1000, 1000, 1000 but it does not start from 1, 1, 1. Please help with this very simple question. If I remove a=2+4 and b=a+7 then it is okay.
for k=1:1000
a=2+4;
b=a+7
for i=1:3
k
end
end

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 30 日
b=a+7
change to
b=a+7;
  2 件のコメント
Muhammad Ahsan
Muhammad Ahsan 2021 年 1 月 31 日
Thank you. I have done this (b=a+7) to (b=a+7;). Actually the problem is that, when I run this code, I get k = 667
k = 668
k = 668
k = 668
k = 669
k = 669
k = ......
The thing is, why it is not starting from k=1, k=1, k=1, .....
Walter Roberson
Walter Roberson 2021 年 1 月 31 日
The rest scrolled off your screen.

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

その他の回答 (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