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

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.

 채택된 답변

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개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 10월 14일

댓글:

2021년 10월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by