In this coding when i am giving m2=0 value, why no graph is coming?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
function dxdt = my_ode(i,x)
% Conversion to first order parameters
% z = x(1); %% displacement of damper
% zdot = x(2); %% velocity of damper
% zddot = x(2)dot; %% acceleration of damper
% y = x(3); %% displacement of structure
% ydot = x(4); %% velocity of structure
% yddot = x(4)dot; %% acceleration of structure
% x = [x(1) x(2) x(3) x(4)]; %% Output parameters
% tspan = i; %% Time span
%% Initial inputs
m1 = 10; %% mass of the structure(kg)
k1 = 15; %% stiffness of the structure(N/m)
c1 = 5; %% damping of the structure(Ns/m)
m2 = 10; %% mass of the damper(kg)
k2 = 15; %% stiffness of the damper(N/m)
c2 = 5; %% damping of the damper(Ns/m)
R = 1; %% Radius of the tank(m)
h = 0.05; %% Height of the water level in tank(m)
g = 9.81; %% Acceleration due to gravity(m/s^2)
A = 0.05; %% Amplitude of ground displacement(m)
w = 6.981; %% Input natural frequencycy(rad/s)
rho = 1000; %% Density of fluid(Kg/m^3)
xi = 1.841; %% First derivative of the Bessel function for first mode
%% define frequency
w2 = sqrt(xi*g*tanh(xi*h/R)/R); %% frequency of damper
w1 = sqrt(k1/m1); %% frequency of structure
%% define damping factor of damper
r2 = c2/(2*m2*w2);
%% define damping factor of structure
r1 = c1/(2*m1*w1);
%% define mass ratio
barm = (((R^3*pi*rho)/(2.2))*tanh(xi*h/R))/(m1);
%% define ground acceleration
ugdd = -A*w^2*sin(w*i);
%% Equation to solve
dxdt = [x(2);
(-ugdd-(2*r2*w2*x(2))-((w2)^2*x(1)));
x(4);
(-ugdd-(2*r1*w1*x(4))-((w1)^2*x(3))+(2*r2*barm*w2)+(barm*(w2)^2*x(1)))];
%% To run mass spring damper system
i = 0:0.01:20;
x = [0 0 0 0];
% Mass matrix function
% M = zeros(4,4);
% M(1,1) = 1;
% M(2,2) = 1;
% M(2,4) = 1;
% M(3,3) = 1;
% M(4,4) = 1;
% opts = odeset('Mass',@(t,x) mass(t,x));
%% Solve using ode45
[tsol,xsol] = ode45('my_ode', i, x,[1 0 0 0 ;0 1 0 1; 0 0 1 0;0 0 0 1]);
%% plotting
plot(tsol,xsol(:,3))
xlabel('time(sec)')
ylabel('displacement(m)')
grid on
title('Displacement response of structure')
figure
plot(tsol,xsol(:,4))
xlabel('time(sec)')
ylabel('velocity(m/s)')
grid on
title('Velocity response of structure')
0 Commenti
Risposte (1)
VBBV
il 2 Mar 2022
When m2 is zero, the ode45 returns NaN values. That's why you don't see the graph
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!