Why is my plot empty?
Show older comments
%%% Solves HW #6 Q2 %%%
% ------ Defining Variables ------ %
y0 = 0;
v0 = 0;
m = 60;
k = round(mean([6,6,0,1]*1000));
b = k/20;
g = 9.81;
Wn = sqrt(k/m);
Xst = (m*g)/k;
L = (b*Wn)/2*k;
tt = linspace(0,5,101);
%%% ------ Closed Form Solution ------ %%%
%%%% BROKEN %%%%
T = tt.*Wn;
A = -Xst;
B = (L*pi*A)/(sqrt(1-L^2));
closed = @(t) exp(-L*pi*t) .* (A*cos(sqrt(1-L^2)*t) + ...
B*sin(sqrt(1-L^2)*t)) + Xst;
subplot(2,2,1)
plot(tt,closed(tt),'-')
title('Closed Form Solution')
xlabel('Time (s)')
ylabel('X(t) (cm)')
Answers (1)
The plot doesn't display because all of the output values (except for tt = 0) are NaN.
L is a relatively large number ~2E6, so for nonzero time values:
exp(-L*pi*t) % this is zero
A*cos(sqrt(1-L^2)*t) % this is -Inf
B*sin(sqrt(1-L^2)*t) % this is -Inf
so 0*Inf = NaN
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!