Filter löschen
Filter löschen

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

34 Ansichten (letzte 30 Tage)
Russell
Russell am 19 Feb. 2015
Kommentiert: Star Strider am 19 Feb. 2015
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.

Akzeptierte Antwort

Star Strider
Star Strider am 19 Feb. 2015
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

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by