필터 지우기
필터 지우기

How do I plot a function of one variable easily in matlab?

조회 수: 16 (최근 30일)
Russell
Russell 2015년 2월 19일
댓글: Star Strider 2015년 2월 19일
This is such a simple thing, I know, I'm just really struggling making it work at all well. I think it's a problem with how I've written the function, something about the element-wise operations. Here's my code:
figure
y = linspace(0,20,0.5);
f = r*y - (r/L_rb)*y.^2 - (p*y.^2)./(q+y.^2);
plot(y,f)
r is 0.65, L_rb is 5.4, p is 1.2 and q is 1. I get a blank plot when I run it.

채택된 답변

Star Strider
Star Strider 2015년 2월 19일
This is one problem:
y = linspace(0,20,0.5);
The third argument to linspace is the length of the vector it produces. (The default is 100.)
See if:
y = linspace(0,20);
improves things

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by