Error using vertcat: dimension of arrays being concenated are not consistent
1 view (last 30 days)
Show older comments
Jouni Salovaara
on 14 May 2019
Commented: Jouni Salovaara
on 14 May 2019
Hello,
I am using xlsread (x=xlsread(filename,sheet,xlrange))
to obtain values for x from my excel file, x is a 27x1 double.
(x=
1.01
1.05
0.004
0.65
etc...)
Then I have matrix A (nx27). I try to call some of the values for A from x, for example(i present just a few rows for the idea):
A= [1 -1 0 1 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; % just some random row
0 0 0 1 -1 0 x(20) 1 0 (x(21)-x(23)) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
A is a jacobian matrix I use , so some elements for A are calculation operations from partial differentials.
When i use this, it gives me the error using vertcat: dimensions of arrays being concatenated are not consistent
The error points to the line where the term 'A=' is. Does it have something to do with it? Anyways, i didnt find an answer after searching for 5 hours from here and trying few things.
Any idea why this happens? is it something with xlsread? I am completely lost with this. Should i use something different for obtaining values for x from excel?
BR,
Jouni
2 Comments
Accepted Answer
Guillaume
on 14 May 2019
The error is simple. At least one of the rows of your A does not have the same number of elements as the others.
Certainly,
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 1 1;
x(13) -x(15) 0 x(17) x(19) -x(20) (x(21)-x(23)) 0 0 0 0 0 x(1) 0 x(2) 0 x(4) 0 x(5) -x(6)
x(7) 0 -x(7) 0 0 0 0;
is clearly wrong since that last row has only 7 elements. Note that newlines in a matrix construction are equivalent to semicolons.
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!