Just wondering if I could get a bit of help on this. How would I change this code to remove the for loop so it operates recursively.
function [x, y] = test(data)c=1;input=data;x=length(input); for z=2:x if input(z-1)>input(z) && input(z)<input(z+1) x(c,1)=z; y(c,1)=input(z); c=c+1 end endend
So far I have tried to change it and gotten
function [x, y] = test(data)c=1;input=data;x=length(input); if length(input(z-1))+2>length(input) return elseif input(z-1)>input(z) && input(z)<input(z+1) x(c,1)=z; y(c,1)=input(z); c=c+1 end endend
But this just runs the if statement once and does not operate recursively.
Best Answer