matlab not plotting graph

9 Ansichten (letzte 30 Tage)
Jalen Gango
Jalen Gango am 2 Aug. 2021
Bearbeitet: the cyclist am 2 Aug. 2021
Any ideas why matlab wont plot this? only getting one value for z but thats not appearing graph either. Where have i gone wrong?
h = [2,4,6,8,10];
x = 10.1;
y = 2.5;
z = (x * h.^2 - x - sqrt(y^2*h.^2 - y^2)) / (h.^2 -1);

Antworten (2)

Rafael Hernandez-Walls
Rafael Hernandez-Walls am 2 Aug. 2021
You need one point in the equation of z
h = [2,4,6,8,10];
x = 10.1;
y = 2.5;
z = (x * h.^2 - x - sqrt(y^2*h.^2 - y^2))./ (h.^2 -1);
plot(h,z)

the cyclist
the cyclist am 2 Aug. 2021
Bearbeitet: the cyclist am 2 Aug. 2021
You are using a matrix division operation rather than an elementwise division. So you need,
h = [2,4,6,8,10];
x = 10.1;
y = 2.5;
z = (x * h.^2 - x - sqrt(y^2*h.^2 - y^2)) ./ (h.^2 -1) % Notice the ./ in this line
z = 1×5
8.6566 9.4545 9.6774 9.7850 9.8487
plot(h,z)

Kategorien

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

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by