Borrar filtros
Borrar filtros

Problem in plotting vectorized inline function.

1 visualización (últimos 30 días)
tauseef ashraf
tauseef ashraf el 29 de Oct. de 2016
Comentada: Star Strider el 29 de Oct. de 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.

Respuesta aceptada

Star Strider
Star Strider el 29 de Oct. de 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 comentarios
tauseef ashraf
tauseef ashraf el 29 de Oct. de 2016
Thanks alot for the help buddy. Greatly appreciated
Star Strider
Star Strider el 29 de Oct. de 2016
My pleasure.
If my Answer solved your problem, please Accept it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Function Creation 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!

Translated by