Why does this loops produce a matrix?

1 回表示 (過去 30 日間)
Douglas Brenner
Douglas Brenner 2018 年 10 月 6 日
コメント済み: Matt J 2018 年 10 月 6 日
code
waves = [393.029, 414.386, 427.176, 516.748, 526.953, 640.000];
l = length(waves);
for i = 1:l
L = waves(i)
p = int32((L - minl)/.001) + 1
end
output
L =
3.930290000000000e+02
p =
342030 338030 337030 347030 344030 340030 338030
L =
4.143860000000000e+02
p =
363387 359387 358387 368387 365387 361387 359387
etc.
The L's are right but where does the answer for p come from? Why is it not a single value?
  2 件のコメント
Matt J
Matt J 2018 年 10 月 6 日
Because minl is not a scalar?
Matt J
Matt J 2018 年 10 月 6 日
Douglas' comment moved here:
Sorry, no
minl =
378.157
L =
3.930290000000000e+02
p =
342030 338030 337030 347030 344030 340030 338030
L =
4.143860000000000e+02

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

採用された回答

Matt J
Matt J 2018 年 10 月 6 日
編集済み: Matt J 2018 年 10 月 6 日
I suspect that minl is really a char array, like '378.157'. Try this instead
p(i) = int32((L(i) - str2double(minl))/.001) + 1;
  1 件のコメント
Douglas Brenner
Douglas Brenner 2018 年 10 月 6 日
Thank you.

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

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