Question
MATLAB HELP: I have this code but I need to plot different values of zeta on the same plot ( that's 4 lines on 1
MATLAB HELP:
I have this code but I need to plot different values of zeta on the same plot ( that's 4 lines on 1 plot)
i.e. zeta = 0.1,1,1.1,2
kindly help
The code works fine with just one value of zeta.
%1-DOF Spring Mass Damper Systems clc; close all; g = 9.81; Y0 = 0; V0 = 0; zeta = 0.1; wn = 2*pi*100; wd = wn*sqrt(abs(1-zeta^2)); A = Y0-(1/wn^2)*g; B = zeta*wn/wd*A+V0/wd; T = 3*2*pi/wn; t = linspace(0,T,300); if zeta < 1 Y = exp(-zeta*wn*t) .*(A*cos(wd*t)+B*sin(wd*t))+((1/wn^2)*g); end if zeta > 1 Y = exp(-zeta*wn*t) .*(A*cosh(wd*t)+B*sinh(wd*t))+((1/wn^2)*g); end if zeta == 1 Y = exp(-zeta*wn*t) .*A+exp(-wn*t) .*t*(V0+wn*A)+((1/wn^2)*g); end figure plot(t,Y); xlabel ( 'Time [sec] ' ); ylabel ( 'y [m]' ); title ( 'Vibration response '); grid on; hold all
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started