フィルターのクリア

Greetings dear friends, I am trying to change some variables in the indicated code to get the waves that can be seen in the 3D graph, thanks for your help!

1 回表示 (過去 30 日間)
By this means the experts helped me with this code for which I am grateful and I have tried to obtain the waves indicated in the final 3D graph that I wish to create:
In the results I see this graph (Which cordially helped me by this means):
The code is this:
Thank you so much!

採用された回答

Simon Chan
Simon Chan 2022 年 3 月 8 日
Better to check the limits to generate your sample figure. Looks like from -3pi to 3pi as shown below:
As the limits goes to infinity, it smears out the oscillation and becomes a straight line. So your code is correct.
clear; clc;
t = linspace(0.001,2,50);
x = linspace(-2,2,50);
[T,X] = meshgrid(t,x);
tiledlayout(3,3,'TileSpacing','compact','Padding','compact');
for k = 1:9
for r = 1:numel(x)
for s = 1:numel(t)
f = @(p) (1/(pi*sqrt(2*pi))).*(sin(p)./p).*exp(-(T(r,s)*p.^2)+i*(p*X(r,s)));
F(r,s) = integral(f,-k*pi,k*pi);
end
end
nexttile
surf(T,X,real(F));
colormap(flip(autumn()));
xlabel('t');
ylabel('x');
zlabel('u(x,t)');
title(sprintf('Limits: -%d%s to %d%s',k,'\pi',k,'\pi'));
end
for r = 1:numel(x)
for s = 1:numel(t)
f = @(p) (1/(pi*sqrt(2*pi))).*(sin(p)./p).*exp(-(T(r,s)*p.^2)+i*(p*X(r,s)));
F(r,s) = integral(f,-3*pi,3*pi);
end
end
figure(2)
surf(T,X,real(F));
colormap(flip(autumn()));
xlabel('t');
ylabel('x');
zlabel('u(x,t)');
  3 件のコメント
Simon Chan
Simon Chan 2022 年 3 月 8 日
Try to clear the workspace or restart MATLAB before running the code.
clear; clc; % <--- Clear the workspace
t = linspace(0.001,2,50);
x = linspace(-2,2,50);
[T,X] = meshgrid(t,x);
for r = 1:numel(x);
for s = 1:numel(t);
f = @(p)(1/(pi*sqrt(2*pi))).*(sin(p)./p).*exp(-(T(r,s)*p.^2)+i*(p*X(r,s)));
F(r,s) = integral(f,-3*pi,3*pi);
end
end
surf(T,X,real(F));
colormap(flip(autumn()));
xlabel('t');
ylabel('x');
zlabel('u(x,t)');
Lewis HC
Lewis HC 2022 年 3 月 8 日
I have to tell you that you are one of the best dear friend, thank you very much, you helped me as you can not imagine, greetings!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by