Find max value in polyfit

Like to find the max value of this polyfit
tmp1=abs(FRF);
q1 = polyfit(f(f>0 & f <50),tmp1(f>0 & f <50),4);
z1 = polyval(q1,f);
plot(f(f>0 & f <50),z1(f>0 & f <50))

Réponses (1)

Matt J
Matt J le 20 Sep 2022
Modifié(e) : Matt J le 20 Sep 2022

1 vote

xcrit=roots(polyder(q1)); %set derivatives to 0
xcrit(imag(xcrit)~=0)=[]; %get rid of non-real solutions
zmax=max( polyval(q1, [0,xcrit',50]) ); %take max over critical points.

3 commentaires

rockstar49
rockstar49 le 20 Sep 2022
Déplacé(e) : Matt J le 20 Sep 2022
this almost worked, however recieved this error for the last line
Torsten
Torsten le 20 Sep 2022
Déplacé(e) : Matt J le 20 Sep 2022
q1 as argument to polyval is missing.
Matt J
Matt J le 20 Sep 2022
Déplacé(e) : Matt J le 20 Sep 2022
Yes, I fixed it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2017a

Modifié(e) :

le 20 Sep 2022

Community Treasure Hunt

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

Start Hunting!

Translated by