Midpoint rule integration Fourier transform
조회 수: 11 (최근 30일)
이전 댓글 표시
Hello,
I created the code for Midpoint rule Integration. I am doing the Fourier transfrom. With the code I can get results and plot just for only one '' t''
value. Struggling with making loop and plot for case t = 0:1:2 . There should be 3 lines in the plot.
If somone could help and give a hint?
Thanks
function[]= midpt()
clc;
xl=-pi; % Lowe limit -L
xu=pi; % Upper limit L
N=2; % INtervals beetween -L and L
D=1;
dx = (xu-xl)/N; % dividing the domain into N subintervals
x = xl:dx:xu;
t = 0:1:2 ; % time
a = xl;
for g = 1:length(t)
f = (@(w) (pi^0.5) * exp((-w^2)/4) * exp (1i*w*x-D*t(g)*w^2)); % FCN
end
for k = 1:N+1
b = a+dx;
M(k,:) = (b-a)* f((a+b)/2); % Midpoint rule
a=b;
I= sum(M); % Integral
end
plot(x, I, 'Linewidth', 2)
xlabel('x')
ylabel('c(x,t)')
axis tight
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!