Filter löschen
Filter löschen

Problem in plotting vectorized inline function.

1 Ansicht (letzte 30 Tage)
tauseef ashraf
tauseef ashraf am 29 Okt. 2016
Kommentiert: Star Strider am 29 Okt. 2016
Hi, I am trying to workout plotting of a vectorized inline function but encountering an error. Please if somebody can help?
My code is
x=(0.5:0.5:4.5); p1 = [1 -7 14 -8]; %defining coefficients of polynomial 1 p2 = [1 -4 3]; %defining coefficients of polynomial 2 p=conv(p1,p1); %convolution of both these polynomial ps=poly2sym(p); %converting polynomial coefficient vectors into symbolic polynomial pt=char(ps); %converting symbolic polynimial to text string pf=inline(pt); %converting text string to inline function pv=vectorize(pf) %converting inline function to vectorized inline function yp1=polyval(pv,x) plot(x, ypi)
But the error being encountered is: Error using polyval (line 67) Inputs must be floats, namely single or double.
Please help.

Akzeptierte Antwort

Star Strider
Star Strider am 29 Okt. 2016
All the calls to the Symbolic Math Toolbox functions don’t make sense.
Just do this:
x=(0.5:0.5:4.5);
p1 = [1 -7 14 -8]; %defining coefficients of polynomial 1
p2 = [1 -4 3]; %defining coefficients of polynomial 2
p=conv(p1,p2); %convolution of both these polynomial
yp1=polyval(p,x);
plot(x, yp1)
Don’t use inline functions, regardless. They’re being (if they’ve not already been) deprecated in favor of ‘Anonymous Funcitons’. See the relevant section of Function Basics for details on writing and using Anonymous Functions.
  2 Kommentare
tauseef ashraf
tauseef ashraf am 29 Okt. 2016
Thanks alot for the help buddy. Greatly appreciated
Star Strider
Star Strider am 29 Okt. 2016
My pleasure.
If my Answer solved your problem, please Accept it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Function Creation 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!

Translated by