フィルターのクリア

How to solve the error "Dimensions of arrays being concatenated are not consistent"

7 ビュー (過去 30 日間)
Katara So
Katara So 2021 年 2 月 7 日
コメント済み: Steven Lord 2021 年 2 月 7 日
I have data of size 170x300 and want to create a matrix for the board of Game of Life but keep getting the error:
Error using vertcat
Dimensions of arrays being concatenated are not consistent
This is my code:
load Data %which the data of size 170x300
[N,M]=size(A)
B = zeros(N,N);
v1 = zeros(1,(N+2));
v2 = zeros(M,1);
A = [v1;v2 B v2;v1];
I did the same thing for a matrix of size N = 16 where the code was:
N=16;
B = zeros(N,N);
v1 = zeros(1,(N+2));
v2 = zeros(N,1);
A = [v1;v2 B v2;v1];
which work perfectly. What do I need to do differently for the bigger matrix? All help is appreciated!

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 2 月 7 日
v2 = zeros(N,1);
However, if you are just going to write all over A anyhow, and you are going to do so with the all-zero values, then
A = zeros(size(A,1)+2);
  7 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 7 日
At what point is it saying that i = 2 when you expect it to be 170 ?
You posted that there is an error
Error in celldestiny (line 2)
n = numneighbours(A,i,j)
but you did not show what the error is and you did not show the code for numneighbours()
Watch out, by the way, for numneighbours() vs numneighbors() . "Neighbours" is of course the correct spelling, but we in Canada are quite accustomed to the people in the USA spelling it incorrectly.
Steven Lord
Steven Lord 2021 年 2 月 7 日
Sorry, Walter, we haven't finished implementing The Queen's MATLAB yet.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConway's Game of Life についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by