Midpoint rule integration Fourier transform

11 ビュー (過去 30 日間)
Nuclear Engineer
Nuclear Engineer 2019 年 4 月 22 日
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 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by