Why do I get the error “Dimensions of arrays being concatenated are not consistent.”?

1.602 visualizaciones (últimos 30 días)
Can anybody help me why my code show me this error when i run it? i have attached my code.
  19 comentarios
Sarvesh
Sarvesh el 6 de En. de 2024
Editada: Sarvesh el 6 de En. de 2024
You could do without the "What else where you expecting?" line. Also it could be better to not misuse words. Its "were" not "where".
Pranav
Pranav el 30 de Jun. de 2024
the matlab community is horrible.
this message is brought to you by python gang.

Iniciar sesión para comentar.

Respuesta aceptada

Roger Wohlwend
Roger Wohlwend el 4 de Jun. de 2014
Editada: MathWorks Support Team el 27 de Nov. de 2018
This error is encountered when you try to vertically concatenate arrays that do not have compatible sizes. For example, to vertically concatenate two matrices A and B, they must have the same number of columns:
A = ones(2,3)
B = ones(5,3)
C = [A; B]
C is a matrix with 7 rows and 3 columns.
However, if B has 4 columns instead of 3, you will get the error. For example,
B = ones(5,4)
C = [A; B]
  3 comentarios
Misrak Seifu
Misrak Seifu el 4 de Jun. de 2014
Now it's giving this error below...
Warning: Control Character '\U' is not valid. See 'doc sprintf' for control characters valid in the format string. > In sample_gui>save_Callback at 225 In gui_mainfcn at 95 In sample_gui at 42 In @(hObject,eventdata)sample_gui('save_Callback',hObject,eventdata,guidata(hObject))

Iniciar sesión para comentar.

Más respuestas (2)

Ivan Dwi Putra
Ivan Dwi Putra el 27 de Nov. de 2019
I have the same error too
this is my code
close all
% Initial Conditions
% x0 = [3; % 3 radians
% 0]; % 0 rad/s
%Parameter Massa
m1 = 650; % massa train set 1 dalam kg
m2 = 650; % massa train set 2 dalam kg
%Parameter Gaya
f1 = 1170; % dalam N
f2 = 1170; % dalam N
t = [0:100:1000];
% System Dynamics
% a = f1./m1 - (0.004 + (0.00032.*(1.5-(0.015.*sin(0.2.*t)-50))));
% b = f2./m2 - (0.0025 + (0.0004.*(1.6-(0.01.*sin(0.3.*t)-50))));
A = [0 1 0 0
0 f1./m1 - (0.004 + (0.00032.*(1.5-(0.015.*sin(0.2.*t)-50)))) 0 0
0 0 0 1
0 0 0 f2./m2 - (0.0025 + (0.0004.*(1.6-(0.01.*sin(0.3.*t)-50))))];
B = [0;
1/m1
0
1/m2];
C = [1 1 1 1];
D = 0;
% Control Law
Q = [1 0 0 0;
0 1 0 0
0 0 1 0
0 0 0 1];
R = [1 0 0 0;
0 1 0 0
0 0 1 0
0 0 0 1];
K = lqr(A,B,Q,R);
% Closed loop system
sys = ss((A - B*K), B, C, D);

kevin harianto
kevin harianto el 8 de Abr. de 2022
I am wondering if there is a way to dynamically adjust this as my error is also error using horzcat, dimensions of the arrays are not consistent: at Location = [Location, ptCloud.Location];
outputFolder = fullfile(tempdir,"Pandaset");
preTrainedMATFile = fullfile(outputFolder,"trainedSqueezeSegV2PandasetNet.mat");
preTrainedZipFile = fullfile(outputFolder,"trainedSqueezeSegV2PandasetNet.zip");
if ~exist(preTrainedMATFile,"file")
if ~exist(preTrainedZipFile,"file")
disp("Downloading pretrained model (5 MB)...");
component = "lidar";
filename = "data/trainedSqueezeSegV2PandasetNet.zip";
preTrainedZipFile = matlab.internal.examples.downloadSupportFile(component,filename);
end
unzip(preTrainedZipFile,outputFolder);
end
% Load the pretrained network.
outputFolder = fullfile(tempdir,"Pandaset");
load(fullfile(outputFolder,"trainedSqueezeSegV2PandasetNet.mat"),"net");
% Read the point cloud.
%Next we shall change the outputfolder to face towards the data_2
outputFolderNew=fullfile("data_2");
ptCloud = pcread(fullfile(outputFolderNew,"0000000000.pcd"));
%Due to the ptCloud being a different data type
%With the above information in mind (trying to reach 64 in height)
% In order to match with the Expected file format we shall append additional matrices of 0
% in order to subsitute for the lack of clear resolution.
%These additional values should allow the raw pcd file matric to meet the
%resolutions demand
% Since we are only trying to influence the resolution
% (pandaSet Ideal resolution being 64x1856x3)
% and not the actual
% value's representation we will only be adding in the values.
Location = zeros(64, 1856, 3);
%next we shall add in the ptCloud.Location values
Location = [Location, ptCloud.Location];
%Now that we have added in the additional resolution we
% shall now create a new ptCloud variable for replacement.
tempPtCloud = ptCloud;
%next we shall change the Location properties.
tempPtCloud.Location = Location;
%Then we shall utilize the new ptCloud and treat it as the original
ptCloud = tempPtCloud;
% Convert the point cloud to 5-channel image.
im = helperPointCloudToImage(ptCloud);
% Predict the segmentation result.
predictedResult = semanticseg(im,net);
% Display sematic segmentation result on point cloud
% This should now be displaying our pointClouds that we want to add in and
% analyze for our use case.
helperDisplayLabelOverlaidPointCloud(im,predictedResult);
view([39.2 90.0 60])
title("Semantic Segmentation Result on Point Cloud")

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by