Greetings dear friends, I am trying to graph this integral so that I can obtain a graph x =f(t), thanks for your help!
1 次查看(过去 30 天)
显示 更早的评论
I need to get this curve in my 3D graph:
My code which I was working is this:
Thank you dear friends!
4 个评论
Paul
2022-2-26
How does exp(i*p*x) in the equation become just cos(p*x) in the code? Unless of course only the real part of the integral is goal.
采纳的回答
Voss
2022-2-25
编辑:Voss
2022-2-25
Note that t > 0 and the grids on the surface in the desired image are more widely spaced than the actual points where the surface has been calculated (i.e., there is curvature in between grid lines).
t = linspace(0.0001,2,50);
x = linspace(-2,2,50);
[T,X] = meshgrid(t,x);
for i = 1:numel(x)
for j = 1:numel(t)
% f = @(p)1/pi*sqrt(2*pi)*sin(p)./p.*exp(-T(i,j).*p.^2).*cos(p.*X(i,j));
f = @(p)1/(pi*sqrt(2*pi))*sin(p)./p.*exp(-T(i,j).*p.^2).*cos(p.*X(i,j));
F(i,j) = integral(f,-Inf,Inf);
end
end
surf(T,X,F);
colormap(flip(autumn()));
xlabel('t');
ylabel('x');
zlabel('u(x,t)');
2 个评论
Torsten
2022-2-25
f = @(p)1/(pi*sqrt(2*pi))*sin(p)./p.*exp(-T(i,j).*p.^2).*cos(p.*X(i,j));
instead of
f = @(p)1/pi*sqrt(2*pi)*sin(p)./p.*exp(-T(i,j).*p.^2).*cos(p.*X(i,j));
Voss
2022-2-25
Oh yeah! Thanks!
I saw your comment before, but then I just typed in the code from the screenshot in the question anyway. D'oh!
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!