Zeros from a spline (csapi and spapi)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Armindo
el 19 de En. de 2019
Editada: John D'Errico
el 19 de En. de 2019
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.
0 comentarios
Respuesta aceptada
John D'Errico
el 19 de En. de 2019
Editada: John D'Errico
el 19 de En. de 2019
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spline Postprocessing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!