Error using plot Data must be numeric, datetime, duration or an array convertible to double.

1 回表示 (過去 30 日間)
This is my code
N=[randi([1,5],1,2),randi([10,50],1,2),randi([100,500],1,2)];
t=[-10:0.01:10];
tau=2*pi/3
for i=1:length(N)
phi = exponential(N(i),t,tau);
subplot(3,1,i)
plot(t, phi,'b-')
end
% and here's my code for the functions
function phi = exponential(N,t,tau)
syms t
w=1;
for i = 1:length(tau)
T = tau(i)
f = (1)
do = (1/(2*pi)) * int(f,t,-T/2,T/2);
doz = double(do)
d0vec(i)=doz
end
for i=1:length(N)
for n=1:N(i)
fun = 1*exp(N*t*w*j);
dn = (1/(2*pi))*int(f*cos(n*pi*t),t,-T/2,T/2);
ddn = double(dn);
dnz(n) = ddn;
end
dnhar{i} = dnz;
end
for i=1:length(N)
ef = 0;
for n=1:N(i)
estf=((dnhar{i}(n))*exp(j*w*N*t));
ef = ef+estf
end
ftarray = ef+doz
end
phi = eval(ftarray);
end
I am supposed to calculate and graph the nth term of fourier exponential series.

採用された回答

KSSV
KSSV 2021 年 10 月 14 日
Variable phi used in the plot is a symbolic variable.
1/3 - (310775629405771*exp(t*4i))/576460752303423488
You cannot plot that striaght away using plot. Read about subs, get tvalues substitute values in there convert them into number using double and then plot.
Read about subs, double.
Also have a look on ezplot, fplot.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by