The code keep giving the error of 'Empty sym: 0-by-2' .
Afficher commentaires plus anciens
The %error line is giving empty values. The values of c,g,l,st,nt,L are arbitrary and for example can be considered (3,1,1,1,1,1). Can someone please help me with the error? This is the code.
c = input('c ');
g = input('g ');
l = input('l ');
st = input('st ');
nt = input('nt ');
L = input ('L');
syms Lambda_n V_R delta_nrt A_r2
for i = 1:c
if i <= c-g
V_R = (l)*kron(kron(A_r2,delta_nrt), eye(nt^(l-1)))
C = kron(kron(eye(L),eye(st^(i-1))), V_R) %error line
B1 = zeros(c+2-i,c+1-i);
for j = 1:c+2-i
for k = 1:c+1-i
if j==k && j==1 && k==1
B1(j,k) = 1;
else B1(j,k) =0
end
end
end
display(B1)
A = zeros(size(B1,1)*size(C,1),size(B1,2)*size(C,2),'sym');
A = kron(B1,C)
put_A_here=logical([zeros(i,1) eye(i)])
big=repmat(sym(0),size(put_A_here).*size(A));
out=big;
small=A;
L= put_A_here;
A=reshape(1:numel(small),size(small));
B=repmat({zeros(size(A))},size(L));
B(L)={A};
B=cell2mat(B);
B=B(:);
out(B~=0)=small(B(B~=0));
D1{i} = out;
else
V_R = (l)*kron(kron(A_r2,delta_nrt), eye(nt^(l-1)))
C = kron(kron(eye(L),eye(st^(i-1))), V_R) ; %error line
B1 = zeros(c+2-i,c+1-i);
for j = 1:c+2-i
for k = 1:c+1-i
if j==k && j==1 && k==1
B1(j,k) = 1;
else B1(j,k) =0;
end
end
end
display(B1)
A2 = zeros(size(B1,1)*size(C,1),size(B1,2)*size(C,2), 'sym');
A2 = kron(B1,C)
put_A_here=logical([zeros(c-g,1) eye(c-g); zeros(1,c-g+1)])
big=repmat(sym(0),size(put_A_here).*size(A2));
out=big;
small=A2;
L= put_A_here;
A2=reshape(1:numel(small),size(small));
B=repmat({zeros(size(A2))},size(L));
B(L)={A2};
B=cell2mat(B);
B=B(:);
out(B~=0)=small(B(B~=0));
D1{i} = out;
end
end
C = blkdiag(D1{:});
2 commentaires
Walter Roberson
le 26 Avr 2020
Your L starts as a scalar. For the first round, eye(L) is valid, because L is a scalar. But later you have
L= put_A_here;
where put_A_here is a vector. Then when eye(L) is used, that fails because eye() does not accept a vector of sizes.
If you are wanting to create an eye() that is L(1) x L(2) then you have to use eye(L(1),L(2)) not eye(L)
raina RAJ
le 26 Avr 2020
Réponses (0)
Catégories
En savoir plus sur Multidimensional Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!