Need help using the for loop

Test case
Check if AdjustMinValue(4, [2, 12, 9, 20], 10) returns [4, 12, 18, 20]

回答 (1 件)

David Hill
David Hill 2019 年 10 月 22 日

0 投票

Not sure why you have to use a for-loop.
function dataSamples = adjustMinValue(dataSamples,minValue)
for i=1:length(dataSamples)
if dataSamples(i)<minValue
dataSamples(i)=2*dataSamples(i);
end
end

2 件のコメント

Jose Grimaldo
Jose Grimaldo 2019 年 10 月 22 日
Code did not work
David Hill
David Hill 2019 年 10 月 22 日
Works for me!

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2019 年 10 月 21 日

コメント済み:

2019 年 10 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by