Matlab while loop/array help.
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
so this is what i have to do. i have an array for example
n = [1 2 3 4 0.555 0.25 7 8];
i have to find the minimum of this array but i have to exclude the 0.555 value since this is an anomaly and then find the minimum after this value has been excluded. the data I am actually working with is much bigger.
does anybody know how to write a while loop for this problem in matlab?
this is what i have tried but it is not giving me the correct answer (i have used a if loop int this one:
clear
clc
n = [1 2 1.5 0.5 0.25 3 4 5 6 7];
k = 1:7;
m = min(n);
for a = 1:7
if(n(a) > m)
x = min(n(a))
%newMin= min(newArray);
end
end
is there any way to do this using a while loop?
thank you, your help is much appreciated
0 Commenti
Risposta accettata
Jonathan Sullivan
il 13 Feb 2012
Mary, there is no need for a while loop. You can do this simply by excluding the value you and, and then taking the min.
exclude_val = 0.555;
m = min(n(n ~= exclude_val));
0 Commenti
Più risposte (1)
Vedere anche
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!