フィルターのクリア

Problem in plotting vectorized inline function.

1 回表示 (過去 30 日間)
tauseef ashraf
tauseef ashraf 2016 年 10 月 29 日
コメント済み: Star Strider 2016 年 10 月 29 日
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.

採用された回答

Star Strider
Star Strider 2016 年 10 月 29 日
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 件のコメント
tauseef ashraf
tauseef ashraf 2016 年 10 月 29 日
Thanks alot for the help buddy. Greatly appreciated
Star Strider
Star Strider 2016 年 10 月 29 日
My pleasure.
If my Answer solved your problem, please Accept it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by