# I need help with the error called 'Error using vertcat Dimensions of arrays being concatenated are not consistent.'

조회 수: 1(최근 30일)
Praneeti Mitra 2021년 5월 26일
댓글: Praneeti Mitra 2021년 5월 29일
I have a piece of code-
position = [0.3189, 0.2189, 0.6320, 0.5320;...
0.1927, 0.0927, 0.3883, 0.2883;...
0.3180, 0.1180, 0.4174, 0.2174;...
0.5303, 0.4303, 0.5302, 0.4302;...
0.7071, 0.6071, 0.6528, 0.5528;...
0.7277, 0.6277, 0.6528, 0.5528;...
0.9107, 0.8107, 0.4419, 0.3419;...
0.9710, 0.6710, 0.4276, 0.1276;...
0.4246, 0.3246, 0.6509, 0.5509;...
0.4246, 0.3246, 0.1785, 0.0785;...
0.5771, 0.4771, 0.6556, 0.5556;]
checkpoint = [0.1; 0.2];
A = [ones(11, 2) position];
M = [diag(checkpoint)-diag(checkpoint); -eye(2) zeros(2); zeros(2) eye(2)];
find(sum(A*M > 0, 2) == 4)
when i run this code it throws error called vertcat dimensions
Howresolve this issue?

댓글을 달려면 로그인하십시오.

### 채택된 답변

David Fletcher 2021년 5월 26일
편집: David Fletcher 2021년 5월 26일
The statement tries to stack a 2x2 on top of a (2x4) x 2
M = [diag(checkpoint)-diag(checkpoint); -eye(2) zeros(2); zeros(2) eye(2)];
x x
x x
x x x x
x x x x
x x x x
x x x x
for it to work the top 2x2 matrix would need to be padded to 2x4
Looking at it diag(checkpoint)-diag(checkpoint) doesn't make much sense - you'd just do zeros(2) in your schema. Maybe you meant to horizontally concatenate diag(checkpoint) with the unary negation of diag(checkpoint)
M = [diag(checkpoint) -diag(checkpoint); -eye(2) zeros(2); zeros(2) eye(2)];
##### 댓글 수: 1표시숨기기 없음
Praneeti Mitra 2021년 5월 29일
thanks

댓글을 달려면 로그인하십시오.

### 범주

Find more on Loops and Conditional Statements in Help Center and File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by