How do I plot an integral of a function as a function?

조회 수: 3 (최근 30일)
Hanah Goetz
Hanah Goetz 2019년 7월 31일
답변: Steven Lord 2019년 7월 31일
I have the following code:
for t=1:1:200
fun = @(n) -2*((v0+v1*K1K2*n.^2)./(1+K1K2*n.^2)-(gamma*n))./((v0+v1*K1K2*n.^2)./(1+K1K2*n.^2)+(gamma*n));
phi= @(x) integral( @(n) fun(n),0,x);
scatter(t,phi(t))
plot(t,phi(t))
line(t,phi(t))
hold on
end
The "scatter" will plot, but not the curve connecting them (which is what I am really interested in).

답변 (1개)

Steven Lord
Steven Lord 2019년 7월 31일
This plots 200 separate scatter plots and 400 line plots (200 from plot, 200 from line) each of which consists of exactly one point.
I can think of two options offhand that will let you do what you want. The first is to store the data into a vector inside the for loop and scatter and/or plot after the loop is complete. The second is to create an animatedline before you enter the for loop and addpoints into that animatedline inside the loop.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by