Midpoint rule integration Fourier transform
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!