How can I plot the following in MATLAB?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Haseeb Ur Rehman
il 3 Giu 2020
Commentato: David Hill
il 6 Giu 2020
Hello Everyone! Could anyone help me plot the following Fourier Cosine series,
,
where the fourier cosine coefficients are
,
, .
I tried the following code for a specific value of n=8 just to check it but it does not give me the correct results.
clear all, clc
syms x t k
for t=0:0.5
bo=1.40985;
bl=-0.443179;
t1=exp(-(k^2)*(pi^2)*t);
t2=k*sin(k*pi*x);
t3=cos(k*pi*x);
S1=symsum((bl*t1*t2),k,1,8);
S2=symsum((bl*t1*t3),k,1,8);
S3=bo+S2;
S4=S1/S3;
u=((-pi)*S4);
end
fplot(u)
0 Commenti
Risposta accettata
David Hill
il 3 Giu 2020
Not sure if this is what you are looking for or not.
for n=0:8
f=@(x)exp((1-cos(pi*x))/pi.*cos(n*pi*x));
b(n+1)=2*integral(f,0,1);
end
b(1)=b(1)/2;
[x,t]=meshgrid(0.09:.0001:.1,0:.0001:.01);
n=zeros(size(x));
d=zeros(size(x));
for bb=2:9
n=n+b(bb)*exp(-bb^2*pi^2*t)*bb*sin(bb*pi*x);
d=d+b(bb)*exp(-bb^2*pi^2*t)*cos(bb*pi*x);
end
d=ones(size(x))*b(1)+d;
u=-pi*n./d;
surf(x,t,u,'EdgeColor','none');
2 Commenti
David Hill
il 6 Giu 2020
for n=0:8
f=@(x)exp((1-cos(pi*x))/pi.*cos(n*pi*x));
b(n+1)=2*integral(f,0,1);
end
b(1)=b(1)/2;
[x,t]=meshgrid(0:.2:1,0:.02:1);
n=zeros(size(x));
d=zeros(size(x));
for bb=2:9
n=n+b(bb)*bb*exp(-bb^2*pi^2*t).*sin(bb*pi*x);%.* element-wise
d=d+b(bb)*exp(-bb^2*pi^2*t).*cos(bb*pi*x);%.* element-wise
end
d=ones(size(x))*b(1)+d;
u=-pi*n./d;
surf(x,t,u,'EdgeColor','none');
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!