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

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