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

 Respuesta aceptada

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 comentarios

Spencer
Spencer el 6 de Oct. de 2023
I completely missed that! Thank you so much, I was litterally pulling my hair out.
Voss
Voss el 6 de Oct. de 2023
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2023a

Etiquetas

Preguntada:

el 6 de Oct. de 2023

Comentada:

el 6 de Oct. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by