Need help using the for loop

3 visualizzazioni (ultimi 30 giorni)
Jose Grimaldo
Jose Grimaldo il 21 Ott 2019
Commentato: David Hill il 22 Ott 2019
Test case
Check if AdjustMinValue(4, [2, 12, 9, 20], 10) returns [4, 12, 18, 20]

Risposte (1)

David Hill
David Hill il 22 Ott 2019
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 Commenti
Jose Grimaldo
Jose Grimaldo il 22 Ott 2019
Code did not work
David Hill
David Hill il 22 Ott 2019
Works for me!

Accedi per commentare.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by