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);endfor 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)]; endendA = [];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}];endC = 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,:) = []; endendAsize(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 🙂
Best Answer