How can I use the lagrangepoly() function on the ecg data

I am trying to use lagrangepoly function on ecg data but it dosen't gives any plot and when I quit debugging, Matlab opens up ''poly.m'' file.
load noisyecg.mat;
x=noisyECG_withTrend;
t=1:length(noisyECG_withTrend)
baseline=linspace(min(t),max(t), length(t));
P = lagrangepoly(t,x);
plot(baseline,polyval(P,baseline),x,t);

4 comentarios

Did you mean: lagrange (120 results)
No results for lagrangepoly.
Suggestions:
Why would you want to do this, anyway?
I'm presuming this would be a pretty long series and the use of this function creates a huge one-piece polynomial with N-1 power.
As the author says, far more likely spline will do you far better.
Also, what is the purpose of the two copies of 1:N--'t' and 'baseline'? The second has to just be the first as it is simply by substitution of variables easily seen to be
linspace(1,N,N) % where N=length(noisyECG_withTrend)
Sir I want to compare results of cubic spline with lagrange.
By applying baseline= linspace(1,t,t) it gives an error that the number of elements should be same.
Using baseline=linspace(min(t),max(t), length(t)) just keeps the debugging on busy and when I quit the debugging, MATLAB pops up poly.m file with a green arrow on line 41 (poly.m)
"baseline= linspace(1,t,t) it gives an error t"
Well, yes, it should. t is already a vector of 1:N where N is the length of your time series.
I was just pointing out that your definition of baseline is no different than the t vector you've already got--there's no purpose in creating two copies of the same thing. I don't follow what your thinking must be in having done so.
What is length(noisyECG_withTrend)?
Looks to me like you've probably just exceeded the limits of the length of the series poly can manage to solve
p = poly(r), where r is a vector, returns the coefficients of the polynomial
whose roots are the elements of r.
That's asking a lot if length(r) is really large as I'm guessing it probably is.
Try doing the calculation in pieces instead and see if can't manage that way (altho I still think it's a Don Quixote-type mission; I see no practical purpose in doing this).

Iniciar sesión para comentar.

Respuestas (0)

Productos

Versión

R2018a

Preguntada:

el 2 de Ag. de 2019

Comentada:

dpb
el 5 de Ag. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by