Need help using the for loop

3 ビュー (過去 30 日間)
Jose Grimaldo
Jose Grimaldo 2019 年 10 月 21 日
コメント済み: David Hill 2019 年 10 月 22 日
Test case
Check if AdjustMinValue(4, [2, 12, 9, 20], 10) returns [4, 12, 18, 20]

回答 (1 件)

David Hill
David Hill 2019 年 10 月 22 日
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!

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

カテゴリ

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