Conversion from double to sum not possible - Plot, please help!

Hello, here is my code:
_______
syms x;
syms theta;
y = exp(-abs(x/pi))
a0 = (1/pi)*int(y,0,pi);
dy = diff(y,1);
k = 1:10;
for i = 1:length(k)
a(i) = ((-1)^(i))*2*dy/(i^2);
end
for i = 1:length(k);
g(i) = a(i)*cos(i*theta);
end
fit = a0 + g;
theta = linspace(-pi,pi,50);
plot(theta,fit);
_____
However I get an error saying "Conversion from double to sym is not possible when I try to plot.
My "fit" equation works just fine., I get an equation in terms of 'theta'. But when I try to plot this equation vs, values of theta, these values are in an array, i get the error.
Can somebody please let me know what I should do, specifically, to fix this?
Thanks!!!!

 採用された回答

Matt J
Matt J 2014 年 5 月 15 日
編集済み: Matt J 2014 年 5 月 15 日

0 投票

You cannot plot "equations". You can only plot points. You must evaluate your fit at the series of points that you would like to plot. Then plot those values.

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 5 月 15 日

編集済み:

2014 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by