Matlab while loop/array help.
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Jonathan Sullivan
2012-2-13
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 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!