フィルターのクリア

"Error using vertcat Dimensions of arrays being concatenated are not consistent." why this error showing?

1 回表示 (過去 30 日間)
function M = mass(t,q)
% Mass matrix function
M = zeros(4,4);
M(1,1) = 1;
M(2,2) = 1;
M(3,3) = 1;
M(4,2) = 1;
M(4,4) = 1;
end
function dqdt = my_ode(t,q)
%% Conversion to first order parameters
% y = q(1); %% displacement of damper
% ydot = q(2); %% velocity of damper
% yddot = q(2)dot; %% acceleration of damper
% z = q(3); %% displacement of structure
% zdot = q(4); %% velocity of structure
% zddot = q(4)dot; %% acceleration of structure
% q = [q(1) q(2) q(3) q(4)]; %% Output parameters
% tspan = i; %% Time span
%% Initial inputs
m1 = 200; %% mass of the structure(kg)
k1 = 15; %% stiffness of the structure(N/m)
c1 = 5; %% damping of the structure(Ns/m)
k2 = 150; %% stiffness of the damper(N/m)
R = 0.5; %% Radius of the tank(m)
h = 0.05; %% Height of liquid in tank(m)
g = 9.81; %% Acceleration due to gravity(m/s^2)
A = 0.05; %% Amplitude of ground displacement(m)
f = 1; %% Input frequencycy(Hz)
rho = 1000; %% Density of fluid(Kg/m^3)
xi = 1.841; %% First derivative of the Bessel function for first mode
fs = 1.111; %% Frequency of structure(Hz)
n = 1; %% Tuning ratio
nu = 10^-6; %% Kinematic viscosity of water(m^2/s)
t = 0:0.1:20; %%Time span
%% Mass of the damper
m2 = ((pi*rho*R^3)/2.2)*tanh(xi*h/R);
%% Damping coefficient of damper
c2 = ((5.78*sqrt(m2*k2))/pi)*sqrt(nu/((R)^1.5*(g)^0.5))*(1+((0.318/sinh(xi*h/R))*(1+((1-h/R)/cosh(xi*h/R)))));
%% structure frequency
w1 = 3.48;
%% damper frequency
w2 = sqrt(xi*g*tanh(xi*(h/R))/R);
%% define damping factor of damper
r2 = c2/(2*m2*w2);
%% define damping factor of structure
r1 = 0.01;
%% define mass ratio
barm = (((R^3*pi*rho)/(2.2))*tanh(xi*(h/R)))/(m1);
%% define ground acceleration
ugdd = A*sin(2*pi*f*t);
%% Equation to solve
dqdt = [q(2)
(-2*r1*w1*q(2))-((w1)^2*q(1))+(2*r2*w2*barm*q(4))+(barm*(w2)^2*q(3))-ugdd
q(4)
-ugdd-(2*r2*w2*q(4))-((w2)^2*q(3))];
clc;
clear all;
%% To run mass spring damper system
tspan = 0:0.1:20;
q = [0 0 0 0];
opts = odeset('Mass',@(t,q) mass(t,q));
%% Solve using ode45
[tsol,qsol] = ode45(@(t,q)my_ode(t,q),tspan,q,opts);
%% plotting
plot(tsol,qsol(:,1))
xlabel('time(sec)')
ylabel('displacement(m)')
grid on
title('displacement response of structure')
figure
plot(tsol,qsol(:,2))
xlabel('time(sec)')
ylabel('velocity(m/s)')
grid on
title('Velocity response of structure')

回答 (1 件)

Torsten
Torsten 2022 年 3 月 24 日
function "my_ode" lacks an "end" statement.
  6 件のコメント
RAJKUMAR SAHA
RAJKUMAR SAHA 2022 年 3 月 26 日
if i delete the line t = 0:0.1:20, then ugdd is taken as zero only.
Torsten
Torsten 2022 年 3 月 26 日
No.
ugdd = A*sin(2*pi*f*t);
with t taken from
function dqdt = my_ode(t,q)
and this t runs from 0 to 20.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by