How to plot the required number of subplots?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
As per my script there should be 40 subplots. but I unable tyo recognize the subplots after 28.
Script as as follows:
clc
xs=8;
v=3;
L=20;
ta=0.2;
t=1;
n=1:1:40;
x=0:0.1:20;
position = 0; % position of plot in subplot
fig_num = 1; % figure() number
for j=1:length(n)
omga(j)=n(j)*pi*v/L;
F(j)=exp(-((n(j)*pi*v*ta).^2)/4);
for i=1:length(x)
u(i)=sin(n(j)*pi*xs/L)*F(j)*sin(n(j)*pi*x(i)/L)*cos(omga(j)*t);
end
position = position + 1;
if position > 40; position = 1; fig_num = fig_num + 1,end
figure(fig_num)
subplot(10,4,position);
plot(x,u)
axis off
%plot(x, u)
end
0 commentaires
Réponse acceptée
Chunru
le 21 Jan 2022
Modifié(e) : Chunru
le 21 Jan 2022
xs=8;
v=1;
L=20;
ta=0.2;
t=1;
n=1:1:40;
%x=0:0.1:20;
x=0:0.1:60;
position = 0; % position of plot in subplot
fig_num = 1; % figure() number
u = zeros(size(x));
for j=1:length(n)
omga(j)=n(j)*pi*v/L;
F(j)=exp(-((n(j)*pi*v*ta).^2)/4);
u = u + sin(n(j)*pi*xs/L)*F(j)*sin(n(j)*pi*x/L)*cos(omga(j)*t);
end
plot(x, u)
3 commentaires
Chunru
le 21 Jan 2022
Extend range of x will make multiple peaks. You may need to check the problem formulation.
Plus de réponses (1)
Chunru
le 21 Jan 2022
Since you have applied an amplitude factor of something like exp(-n.^2). The amplitude quickly drop to zero at larger iteration.
xs=8;
v=3;
L=20;
ta=0.2;
t=1;
n=1:1:40;
x=0:0.1:20;
position = 0; % position of plot in subplot
fig_num = 1; % figure() number
for j=1:length(n)
omga(j)=n(j)*pi*v/L;
F(j)=exp(-((n(j)*pi*v*ta).^2)/4);
fprintf('%3d %20.7g\n', j, F(j));
for i=1:length(x)
u(i)=sin(n(j)*pi*xs/L)*F(j)*sin(n(j)*pi*x(i)/L)*cos(omga(j)*t);
end
position = position + 1;
if position > 40; position = 1; fig_num = fig_num + 1,end
figure(fig_num)
subplot(10,4,position);
plot(x,u)
axis off
%plot(x, u)
end
You can use a smaller value or ta or v in order to see more nonzero plot.
v=0.3;
figure;
position = 0; % position of plot in subplot
fig_num = 1; % figure() number
for j=1:length(n)
omga(j)=n(j)*pi*v/L;
F(j)=exp(-((n(j)*pi*v*ta).^2)/4);
fprintf('%3d %20.7g\n', j, F(j));
for i=1:length(x)
u(i)=sin(n(j)*pi*xs/L)*F(j)*sin(n(j)*pi*x(i)/L)*cos(omga(j)*t);
end
position = position + 1;
if position > 40; position = 1; fig_num = fig_num + 1,end
figure(fig_num)
subplot(10,4,position);
plot(x,u)
axis off
%plot(x, u)
end
3 commentaires
Voir également
Catégories
En savoir plus sur Orange dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!