I want to make a series using max & mins of this Integral and show that the series converges and has the limit pi/2.

1 vue (au cours des 30 derniers jours)
clc
close all
clear all
fun=@(w)(sin(w)/w);
f=zeros(1,1000);
for u=1:1000
f(u)=integral(fun,1,u,'ArrayValued',true);
end
plot(f)
I've done the first part but I'm stuck in making a series.
Original question:

Réponse acceptée

Rik
Rik le 26 Fév 2021
Your code already is making a series. You could add the envelope, but the only thing you're missing in my opinion is adding the pi/2 line.
You misunderstood the ArrayValued flag: "Set this flag to true or 1 to indicate that fun is a function that accepts a scalar input and returns a vector, matrix, or N-D array output." Your function does not return an array. A small modification will allow array input.
%clc,close all,clear all
%these are not needed here and are a sign of cargo cult programming.
fun=@(w)(sin(w)./w);
% ^ use elementwise division to allow array input
f=zeros(1,1000);
for u=1:1000
f(u)=integral(fun,1,u,'ArrayValued',false);
end
plot(f)
hold on
%add the envelope
[y_hi,y_lo]=envelope(f,300);plot(y_hi),plot(y_lo)
%add pi/2 to see if that is the value this converges to
yline(pi/2)
%as it apparently doesn't, lets see what it seems to converge to:
fprintf('pi/%.2f\n',pi/f(end))
pi/5.03
%We can repeat this assuming the sine should be computed for degrees instead of radians:
fprintf('pi/%.2f\n',pi/(integral(@(w)(sind(w)./w),1,u)))
pi/2.03
  2 commentaires
John Barton
John Barton le 26 Fév 2021
Thanks for your help. Is there any good sources you can suggest that help me learn this language better?
Rik
Rik le 26 Fév 2021
The best advice I can give you is here. To learn the basics you can de the Onramp tutorial.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by