How to plot an integral a function handle

조회 수: 4 (최근 30일)
Johan Johan
Johan Johan 2018년 5월 6일
댓글: Fanzheng Liu 2021년 11월 13일
I want to plot an integral function, if 'y' is an arbitrary vector ,
N=51;
I=@(x)norm(exp(-1i*pi*x)- y'.*exp(-1i*pi*x*(0:(N-1)))).^2;
F=integral(I,-1,1,'ArrayValued',true);
plot(F);
This what I've tried, but it's not working.

채택된 답변

Star Strider
Star Strider 2018년 5월 6일
I am not certain what you want.
Try this:
N = 51;
I = @(x,y) norm(exp(-1i*pi*x)- y'.*exp(-1i*pi*x*(0:(N-1)))).^2;
F = @(y) integral(@(x) I(x,y), -1, 1,'ArrayValued',true);
y = 1:10;
Fy = arrayfun(F, y);
figure(1)
plot(y, Fy)
grid
  댓글 수: 1
Fanzheng Liu
Fanzheng Liu 2021년 11월 13일
Thank you so much for your code... It really really helped me A LOT!!! 🥺🥺🥺

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by