error-CAT arguments dimensions are not consistent.

9 visualizaciones (últimos 30 días)
kash
kash el 29 de En. de 2012
i have a code
out = [d1, d(ismember(d(:,1),d1(:,1),'rows'),1:end)]
my values are
d=[1 2 3 ;5 6 8 ]
d1=[1 ;1]
i need the answer as
1 1 2 3
1 1 2 3
please help
  1 comentario
kash
kash el 29 de En. de 2012
i get error wen my code is
out = [d1, d(ismember(d(:,1),d1(:,1),'rows'),1:end)]
error is
CAT arguments dimensions are not consistent
please help

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de En. de 2012
d(:,1) is [1;5] . d1(:,1) is [1;1] . You ask ismember() for matching rows. The row [1] of d(:,1) matches the row [1] of d1(:,1) so the first value returned by ismember() is true. The row [5] of d(:,1) does not match any rows of dl(:,1) so the second value returned by ismember is false. The ismember result is thus [true;false] . You use that [true;false] as the first index of d, and you select all columns of d through the second index, so the result is going to be to select just the first row, d(:,1) which is [1 2 3]. You try to combine that single row via horzcat, with the multiple rows of d1, so you get an error.
The above is why you get an error. In order for us to show you how to get the output you want, you will need to explain the rules you want.
I note that if you were to use
[tf, ua, ub] = ismember(d1(:,1), d(:,1), 'rows'); %d1 and d change places
out = [d1(tf), d(ub,:)];
then that would happen to give the output you say you need. This is probably just a coincidence, however.
  7 comentarios
kash
kash el 29 de En. de 2012
Thanks walter,
in other code
ind=nchoosek(1:100,2);
data12=[1:100]
FC1=data12(ind)
my FC1 has 2 column of 4900 rows,but i need 2 columns and 50 rows,by seleccting some values ,please help
for example selecting 2 values from each 100 ,(wen selecting column values must not change)
Walter Roberson
Walter Roberson el 29 de En. de 2012
You have an existing Question for that, http://www.mathworks.com/matlabcentral/answers/27353-selecting-top-values . It can be discussed there.

Iniciar sesión para comentar.

Categorías

Más información sobre Fluid Dynamics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by