how do i plot these 3 graphs on the same plot?
Show older comments
I am getting an error that says "Conversion to logical from sym is not possible". Does anybody know how to correct this? also i commented out two of the 3 y(t) functions just to focus on one equation.
%%displacement of accelerometer on cantilever beam
clc
clear all
v0=0;
x0=-0.04; % intial displacement in meters
% Damping ratios for no damp (zo), one damp (z1), two damp strips(z2)
z0=0.01253723687;
z1=0.01111522908;
z2=0.008548882398;
% natural and angular frequency
wn=104.0889631;
% damped angular frequency
wd0=wn*sqrt(1 - (z0^2));
wd1=wn*sqrt(1 - (z1^2));
wd2=wn*sqrt(1 - (z2^2));
% A is the coefficient for the displacement equation
A0=sqrt((v0 + z0*wn*x0)^2 +(x0*wd0)^2)/wd0;
A1=sqrt((v0 + z1*wn*x0)^2 +(x0*wd1)^2)/wd1;
A2=sqrt((v0 + z2*wn*x0)^2 +(x0*wd2)^2)/wd2;
% phi
phi0=atan((v0 + z0*wn*x0)/(x0*wd0));
phi1=atan((v0 + z1*wn*x0)/(x0*wd1));
phi2=atan((v0 + z2*wn*x0)/(x0*wd2));
% time, t
syms t
% displacement equation
y0=A0*exp(-z0*wn*t)*cos(wd0*t-phi0);
while y0 >= 0.000001
plot(t,y0)
end
% y1=A1*exp(-z1*wn.*t)*cos(wd1.*t-phi1);
% y2=A2*exp(-z2*wn.*t)*cos(wd2.*t-phi2);
% plot all three displacement equations on one graph
Answers (1)
Star Strider
on 1 Mar 2018
I would use subplot:
% displacement equation
y0=A0*exp(-z0*wn*t)*cos(wd0*t-phi0);
y1=A1*exp(-z1*wn.*t)*cos(wd1.*t-phi1);
y2=A2*exp(-z2*wn.*t)*cos(wd2.*t-phi2);
% plot all three displacement equations on one graph
figure(1)
subplot(3,1,1)
fplot(y0, [0 10])
axis([0 10 -0.05 0.05])
grid
subplot(3,1,2)
fplot(y1, [0 10])
axis([0 10 -0.05 0.05])
grid
subplot(3,1,3)
fplot(y2, [0 10])
axis([0 10 -0.05 0.05])
grid
Categories
Find more on 2-D and 3-D 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!