How to plot the required number of subplots?
조회 수: 4 (최근 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!