I am trying to plot an equation however once i run the code, the graph that appears is empty... any idea on the error behind this?
x = 0:0.01:1;
y = (0.5*(1-x))/(5-x);
plot(x,y)

Antworten (1)

Sam Chak
Sam Chak am 20 Apr. 2022
Bearbeitet: Sam Chak am 20 Apr. 2022

0 Stimmen

Because you forgot the 'dot' when dividing corresponding elements in the x vector.
x = 0:0.01:1;
y = (0.5*(1-x))./(5-x);
plot(x,y)
You can see this example clearly:
x = 1:10
data = [x' x'.^2]
data =
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 20 Apr. 2022

Bearbeitet:

am 20 Apr. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by