find x intercepts numerically
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Elizabeth Ramsey
am 25 Mai 2020
Kommentiert: Elizabeth Ramsey
am 25 Mai 2020
I'm trying to find a quick way of returning the index of all the places where an [x,y] data set crosses the x axis.
I've tried: zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0)
But it isn't returning all the zeros and also always returns the last value in my dataset as a zero even though it isn't. I'm testing with a third order polynomial and can only get my code to work if it have only one root.
Thanks!
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 25 Mai 2020
Bearbeitet: Ameer Hamza
am 25 Mai 2020
Try this
f = @(x) find(diff(sign(x)));
Example
>> x = [1 2 -1 -2 -1 2 3 1 -2 -3 -2 1];
>> f(x)
ans =
2 5 8 11
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!