matlab not plotting graph
조회 수: 9 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
답변 (2개)
Rafael Hernandez-Walls
2021년 8월 2일
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)
댓글 수: 0
the cyclist
2021년 8월 2일
편집: the cyclist
2021년 8월 2일
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
plot(h,z)
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!