How to solve the error "Dimensions of arrays being concatenated are not consistent"
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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!
0 Kommentare
Antworten (1)
Walter Roberson
am 7 Feb. 2021
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 Kommentare
Walter Roberson
am 7 Feb. 2021
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.
Siehe auch
Kategorien
Mehr zu Conway's Game of Life finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!