Comparing elements in a 2d array
1 次查看(过去 30 天)
显示 更早的评论
I would like to know if it is possible to find the peak numbers, numbers that are larger then the value befroe and value after. Thank you in advance
array = [1 2 1 3 4 6 4];
peak = 0;
for i = 1:length(array)
if array(i) > array(i)-1||array(i)<array(i)+1
peak = peak + 1;
end
end
disp(peak);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!