I am new to matlab. I have to create a cell in which each matrix is different from the earlier cell entries. Hence i am writng the code such that each matrix is checked before it is stored in cell with all previous matrix in the cell. That means, W{4} would be stored in the cell only if W{1},W{2},W{3} are different from W{4}. Can anyone help ? Thanks in advance.
clc;clear all;n = 2;W=cell(5,1);% Different Matrix
i=1;% initialization
while i<6 % Iterations
a = zeros(n+1, 2) a(randperm(numel(a), n)) = 1 %W{i}=a(:,:);
A=a(:,:) if (sum(A(1,:))>=1) && (sum(A(n+1,:))==0) A_new=A(:,:) for j=1:i * *if W{j}~=W{i} %** Each matrix in the Cell should be different
W{j}=A_new end end% elseif sum(A_new(4,:))<=0
%W{i}=A_new;
i=i+1; endend
Best Answer