plotting, no graph appears

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)

回答(1 个)

Sam Chak
Sam Chak 2022-4-20
编辑:Sam Chak 2022-4-20
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

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by