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
  댓글 수: 2
John Barton
John Barton 2021년 2월 26일
Thanks for your help. Is there any good sources you can suggest that help me learn this language better?
Rik
Rik 2021년 2월 26일
The best advice I can give you is here. To learn the basics you can de the Onramp tutorial.

댓글을 달려면 로그인하십시오.

추가 답변 (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