Why won't my plot work? (not elementwise issue)

Displaying T and d show this isn't an issue with elementwise operations (which is all I can find searching through the questions). Other plots have worked, so I know its not a graphics card issue, but I'm new to Matlab and can't see what's different from this plot and ones that have worked in the past. This is driving me insane, any help would be greatly appreciated.
format compact
clear all
close all
lCable = 2;
lPole = 2;
m = 100;
g = 9.81;
w = m*g;
d = linspace(1,1.9,19);
top = w*lCable*lPole;
bottom = d.*sqrt((lPole^2)-(d.^2));
T = top./bottom;
% T = (w*lCable*lPole)./(d.*sqrt((lPole^2)-(d.^2)))
disp(T);
figure()
plot(d,T)
xlim([0 2])
ylim([0 4])
title("Tension of Cable by Distance")
xlabel("distance (Meters)")
ylabel("Tension (Newtons)")
grid on

 채택된 답변

Voss
Voss 2023년 10월 6일
The T values are around 2000 to 3500 but the ylim was set to [0 4]. I changed the ylim to [0 4000].
format compact
clear all
close all
lCable = 2;
lPole = 2;
m = 100;
g = 9.81;
w = m*g;
d = linspace(1,1.9,19);
top = w*lCable*lPole;
bottom = d.*sqrt((lPole^2)-(d.^2));
T = top./bottom;
% T = (w*lCable*lPole)./(d.*sqrt((lPole^2)-(d.^2)))
disp(T);
1.0e+03 * 2.2655 2.1955 2.1357 2.0853 2.0438 2.0107 1.9860 1.9698 1.9624 1.9646 1.9775 2.0030 2.0438 2.1041 2.1909 2.3158 2.5006 2.7911 3.3071
figure()
plot(d,T)
xlim([0 2])
ylim([0 4]*1e3)
title("Tension of Cable by Distance")
xlabel("distance (Meters)")
ylabel("Tension (Newtons)")
grid on

댓글 수: 2

Spencer
Spencer 2023년 10월 6일
I completely missed that! Thank you so much, I was litterally pulling my hair out.
Voss
Voss 2023년 10월 6일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

릴리스

R2023a

태그

질문:

2023년 10월 6일

댓글:

2023년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by