Zeros from a spline (csapi and spapi)

1 次查看(过去 30 天)
I am using a cubic spline like this:
Spl = csapi (Time_t, Sig);
Out= fnval(Spl,Time_t);
After this I need to extract all the indexs from the spline when the curve goes from:
Positive to Negative values - I need the indexes where the Spl is Zero (or close to zero)
and from
Negative to Positive values - I need the indexes where the Spl is Zero (or close to zero)
But I am not seeing and eficient whay to do this, any help would be apreciated.

采纳的回答

John D'Errico
John D'Errico 2019-1-19
编辑:John D'Errico 2019-1-19
Download my SLM toolbox. Well, not because you need to use the SLM engine itself, but because you want to use slmsolve. The nice thing is, it can work on the pp form produced by csapi.
Spl = csapi (1:10,rand(1,10) - .5);
Spl
Spl =
struct with fields:
form: 'pp'
breaks: [1 2 3 4 5 6 7 8 9 10]
coefs: [9×4 double]
pieces: 9
order: 4
dim: 1
x0 = slmsolve(Spl,0)
x0 =
2.37436802433669 3.52837291901417 5.18859998252568 7.8567313904662
So there were 4 zero crossings for that particular randomly generated curve.
If you need to know which of those roots are cases where the curve went from negative to positive, then just evaluate the derivative of the curve at those locations.
fnval(fnder(Spl,1),x0) > 0
ans =
1×4 logical array
0 1 0 1

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by