How to plot the required number of subplots?
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Chunru
2022 年 1 月 21 日
編集済み: Chunru
2022 年 1 月 21 日
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 件のコメント
Chunru
2022 年 1 月 21 日
Extend range of x will make multiple peaks. You may need to check the problem formulation.
その他の回答 (1 件)
Chunru
2022 年 1 月 21 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!