Error - Brace indexing is not supported for variables of this type.

2 visualizaciones (últimos 30 días)
Hi all,
I'm trying to find a matrix C that does not contain certain rows a{count4} where count4 = 1:N (N is an input). To do this I'm using the function setdiff but it does not seem to work within the for loop, but works outside of the loop. Here is my code:
function [] = Lyapunov(l,k,n,N)
for count = 1:n
e(count) = (1/(2*count*(count+1)))^(1/2);
end
for count2 = 1:n
if count2 == 1
w{count2} = [2*e(1) zeros(1,n-count2)];
else
w{count2} = [e(1:(count2-1)) (count2+1)*e(count2) zeros(1,n-count2)];
end
end
A = [];
x = randi([-1 1],1,N);
y = randi([-1 1],1,N);
for count3 = 1:N
a{count3} = [x(count3) y(count3)];
A = [A;a{count3}];
end
C = setdiff(A,a{1},'rows') %this works
for count4 = 1:N
C = setdiff(A,a{count4},'rows'); %this does not work
c = size(C,1);
a = size(A,1);
if c<a-1
A(count4,:) = [];
end
end
A
size(A,1)
end
and here is the error message:
Brace indexing is not supported for variables of this type.
Error in Lyapunov (line 21)
C = setdiff(A,a{count4},'rows');
I would appreciate any help you all can give me, thank you in advance :)
  2 comentarios
madhan ravi
madhan ravi el 13 de Jul. de 2020
An example matrix with desired result would help.
Jenny Ward
Jenny Ward el 13 de Jul. de 2020
So if A is as follows
A =
1 1
-1 0
1 0
0 0
1 0
-1 0
1 1
-1 -1
0 0
1 -1
and for example a{1} is
ans =
1 1
then C would be A with all rows equal to a{1} removed
C =
-1 -1
-1 0
0 0
1 -1
1 0
and ideally I'd be able to do this for a{1}, a{2} etc. where they are rows of the matrix A.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Jul. de 2020
a = size(A,1);
That replaces the cell a with a numeric scalar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by