Comparing elements in a 2d array
1 view (last 30 days)
Show older comments
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!