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 次查看(过去 30 天)
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:

采纳的回答

Rik
Rik 2021-2-26
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by