How to use a for loop to display zeros of a function
Show older comments
Hello I am writing a small program in matlab to get familiar with it to find the zeroes of a function. Here is my problem, the program only displays 1 zero of the function and not all. Basically the program is displaying the last zero it finds instead of all the zeros. I am trying to modifiy it but it isn't working here is what I've got so far
function zerosOfF=zerosOfF(f);
N=max(size(f));
z=f(1);
for k=2:N
if f(k)*f(k-1)<0; z=-z; zerosOfF=k;
for zerosOfF=k:N
disp(zerosOfF);
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!