Dimensions of arrays being concatenated are not consistent.

2 次查看(过去 30 天)
Hello there,
When I run my programm it says the error message written in the tittle. It says that for the 1st row of matrix A (line 79). Any suggestions?
Thanks.
P.S. I've uploaded the file in the message.

采纳的回答

Stephan
Stephan 2021-7-5
clc;
clear all;
close all;
%% Parametri
%% Inercija; {kg.m2}
Juc = 2.6e-2;
Jlc = 1e-3;
%% Krutost; {N.m/rad}
kuc = 114.59;
klc = 687.55;
kr = 400000;
%% Prigusenje; {N.m.s/rad}
duc = 6e-2;
dlc = 6;
dr = 12000;
%% Radijus; {m}
rpin = 7.78e-3;
%% Sila; {N}
Fr = 1;
Flim = 75;
Flim_column = 0.2;
Flim_torsion = 0.01;
%% Masa; {kg}
mr = 10;
%% Moment; {N.m}
MsAmp = 4.5;
%% Kutna brzina; {rad/s}
freq = 2;
%%
Kt = {0.3 , 'N.m/a'};
J = 0.01;
b = 0.1;
L = 0.5;
R = 1;
K = 0.01;
kESF = 8e6;
kESF_column = 7000;
kESF_torsion = 7000;
%% Ulazni podatci
time = 0.01: 0.01: 0.2;
Ms = MsAmp*sin(2*pi*freq*time);
dm = 0;
Jm = 0;
%% Algoritam prema kojem se racuna I iz Ms
if Ms >=3.5
I = 21.29*Ms-69.4;
elseif Ms < 3.5 & Ms >= 2
I = 2.73 * Ms - 4.47;
elseif Ms < 2 & Ms >= 0
I = 0.5 * Ms;
elseif Ms < 0 & Ms >= (-2)
I = 0.5 * Ms;
elseif Ms < (-2) & Ms >= (-3.5)
I = 2.73 * Ms + 4.47;
elseif Ms < (-3.5)
I = 21.29 * Ms + 69.4;
end
%% Matrice A, B, C i D
A = [0 1 0 0 0 0 0 0 0;
-kuc/Juc -duc/Juc kuc/Juc duc/Juc 0 0 0 0 0;
0 0 0 1 0 0 0 0 0;
kuc/Jlc duc/Jlc -kuc/Jlc -duc/Jlc -klc/Jlc -dlc/Jlc klc/Jlc*rpin dlc/Jlc*rpin 0;
0 0 0 0 0 1 0 0 0;
0 0 0 0 0 0 0 1 0;
0 0 0 0 -klc/mr*rpin -dlc/mr*rpin klc/mr*rpin dlc/mr*rpin 0;
0 0 0 0 0 0 0 0 1;
0 0 0 0 0 0 0 0 -dm/Jm];
B = [0 0 0;
1 -K 0;
0 0 0;
0 K/Jlc 0;
0 0 0;
0 0 0;
0 0 1;
0 0 0;
0 K/Jm 0];
C = B.';
D = 0;
  2 个评论
Frane
Frane 2021-7-5
编辑:Frane 2021-7-5
It works. Can you tell me what did you change so I know in the future?
Stephan
Stephan 2021-7-6
A = [0 1 0 0 0 0 0 0 0;
-kuc/Juc -duc/Juc kuc/Juc duc/Juc 0 0 0 0 0;
0 0 0 1 0 0 0 0 0;
kuc/Jlc duc/Jlc -kuc/Jlc -duc/Jlc -klc/Jlc - dlc/Jlc klc/Jlc*rpin dlc/Jlc*rpin 0;
% ^
% |
% ---- change this
A = [0 1 0 0 0 0 0 0 0;
-kuc/Juc -duc/Juc kuc/Juc duc/Juc 0 0 0 0 0;
0 0 0 1 0 0 0 0 0;
kuc/Jlc duc/Jlc -kuc/Jlc -duc/Jlc -klc/Jlc -dlc/Jlc klc/Jlc*rpin dlc/Jlc*rpin 0;
% ^
% |
% ---- to this. Otherwise MATLB
% interprets:
% -klc/Jlc - dlc/Jlc
% as one expression, which leads
% to having one column
% missing. Better: use
% comma to seperate
% entries in matrices
% and vectors

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by