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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by