Lỗi dimensions of matrices being concatenated are not consistent năm 2024

I have a matrix with 94 nodes and label's file with 94 coordinates. However, when I try run Brainnet with commands I get this error:

Error using horzcat Dimensions of matrices being concatenated are not consistent.

Error in BrainNet_MapCfg (line 133) surf.sphere = [cell2mat(data(1)) cell2mat(data(2)) cell2mat(data(3)) cell2mat(data(4)) cell2mat(data(5))];

I have checked the number of nodes and egdes, but the number is correct (in my case 94). I've gotten the nodes coordinates with getcog and I checked the origin, size voxel in the image with the labels (I used MINDBOGGLE atlas)

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

fati-a

unread,

Apr 5, 2018, 7:06:17 PM4/5/18

to YALMIP

Hello Johan

I have a problem about Dimensions of matrices, this problem is very strange for me because dimensions of parameter and controller are the same but still, there is this error :

Error using vertcat

Dimensions of matrices being concatenated are not consistent.

Error in eliminatevariables (line 249)

involved = [involved;find(m ~= fix(m) | m < 0)];

Error in optimizer/subsref (line 122)

[self.model,keptvariables,infeasible] =

eliminatevariables(self.model,self.parameters,thisData(:));

Error in cc_mpc2 (line 275)

[sol,err] = controller{{P.x_k,alpha_tot(24*20+k:24*20+k+P.Hp-1,:),...

could you please help me for solving this problem?

Thanks

Johan Löfberg

unread,

Apr 5, 2018, 7:46:32 PM4/5/18

to YALMIP

The optimizer does not like models which have signomial parameterizations in models that are intended to be solved with a simple QP solver. Hence, your A matrix should not be parameterized in x, but you should define new variables beta and let these be parameters, and compute these this from x before you call the controller object. That will also lead to much less overhead in every controller call, since a lot of symbolic processing can be removed

fati-a

unread,

Apr 5, 2018, 8:28:13 PM4/5/18

to YALMIP

Dear Johan

Thank you for quick answer.

I change the matrix A of my model and now the model is not signomial but still, there is the same problem .

Error using vertcat

Dimensions of matrices being concatenated are not consistent.

Error in cc_mpc2 (line 282)

[sol,err] = controller{{P.x_k,...

Thanks

Johan Löfberg

unread,

Apr 5, 2018, 8:45:35 PM4/5/18

to YALMIP

That's because the following code fails due to your commenting

`>> {P.x_k,

% alpha_tot(24*20+k:24*20+k+P.Hp-1,:),...

alpha_tot(k:k+P.Hp-1,:),...

D{mod(P.Hp+k-1,P.Hp)+1},...

Dd{mod(P.Hp+k-1,P.Hp)+1},...

bs{mod(P.Hp+k-1,P.Hp)+1},...

devX{mod(P.Hp+k-1,P.Hp)+1}

`

`}

Error using vertcat

Dimensions of matrices being concatenated are not consistent.

`

...and once you've fixed that it will still fail as the dimensions in the parameter list is not consistent with the data that you send

Hello. I have a series of output A=2, B=3, C=4,D=5, E=[1;0.1;0.9]. I'm trying to put all of these output together as a row matrix, F. i.e F = [A B C D E]. But i keep getting the error 'Dimensions of matrices being concatenated are not consistent'. Is there a solution to this please?

3 Comments

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

Dimensions of matrices being concatenated are not consistent.

Function: gradientDescent

FileName: C:\Users\oguns\Desktop\MATLAB Projects\gradientDescent.m

LineNumber: 14

This is The error it says please... I dont seem to understand, cause in that specific line 14, the dimensions seems to be right.. m=97, and data is a 97x2 matrix.. can any one help please?

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

I can't run an image. Post your script - your m-file - in a NEW question (not here in Chiamaka's 3 year old question). In the meantime, try using a semicolon to concatenate the column vector onto your scalar

X = [ones(m, 1); data(:, 1)];

This will stitch them one above the other, so if m=2:

1

1

d

d

d

Using a comma tries to stitch the data column vector to the right of a single number, so if m is 2:

1 d

1 d

d

Which won't work because all columns must have the same number of rows.

Sign in to comment.

Accepted Answer

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

  • Direct link to this answer

  • #### Direct link to this answer

Because E is a column vector, not a row vector like you're building with all the rest of the numbers, you must transpose E:

A=2

B=3

C=4

D=5

E=[1; 0.1; 0.9]

F = [A, B, C, D, E']

so now F is a row vector. Or else use semicolons and don't transpose E:

A=2

B=3

C=4

D=5

E=[1; 0.1; 0.9]

F = [A; B; C; D; E]

so now F is a column vector.

1 Comment

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

That worked. Thank you very much

Sign in to comment.

More Answers (2)

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

  • Direct link to this answer

  • #### Direct link to this answer

A=2

B=3

C=4

D=5

E=[1; 0.1; 0.9]

F = [A, B, C, D, E']

2 Comments

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

Yes, exactly what I said in my first answer.

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

Sometimes inconsistence comes because your function def argu arrangments, and calling arg arrangements are not match. hope it will help too.

Sign in to comment.


Lỗi dimensions of matrices being concatenated are not consistent năm 2024

  • Direct link to this answer

  • #### Direct link to this answer

\>> A=['a' , 'b ';'c' ,'b']

Dimensions of matrices being concatenated are not consistent.

Help

1 Comment

Lỗi dimensions of matrices being concatenated are not consistent năm 2024

Direct link to this comment

  • Direct link to this comment

This is an error you have because you're trying to make a character array with 3 characters in the first row (a, b, and a space), and two in the second row (c and b). If you get rid of the space it will work:

A=['a', 'b'; 'c', 'b']

A = 2×2 char array

'ab' 'cb'

Sign in to comment.

See Also

Categories

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.