Midpoint rule integration Fourier transform

11 vues (au cours des 30 derniers jours)
Nuclear Engineer
Nuclear Engineer le 22 Avr 2019
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

Réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by