Assignment has more non-singleton rhs dimensions than non-singleton subscripts
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi i have a thesis and in my work,i need to write a code in matlab but when i run it,matlab said: "Assignment has more non-singleton rhs dimensions than non-singleton subscripts" please help me for this
i want A(matrix 3*3) and i have all of a11vec,a12vec,a13vec,a21vec,a22vec,a23vec,a31vec,a32vec,a33vec
%A is amatrix(3*3)
A=zeros(l, m, kindex, j, n+1);
for l=1:4
for m=1:8
K=1:.25:3;
for kindex=1:9
for j=1:8
for n=[0, 1]
A(l, m, kindex, j, n+1)=[a11vec(l, m, kindex, j, n+1),a12vec(l, m, kindex, j, n+1),a13vec(l, m, kindex, j);a21vec(l, m, kindex, j, n+1),a22vec(l, m, kindex, j, n+1),a23vec(l, m, kindex, n+1);a31vec(l, m, kindex, j),a32vec(l, m, kindex, n+1),a33vec(l, m, kindex, j, n+1)];
end
end
end
end
end
댓글 수: 0
채택된 답변
OCDER
2017년 10월 16일
In this statement:
A(l, m, kindex, j, n+1)=[a11vec(l, m, kindex, j, n+1),a12vec(l, m, kindex, j, n+1),a13vec(l, m, kindex, j);a21vec(l, m, kindex, j, n+1),a22vec(l, m, kindex, j, n+1),a23vec(l, m, kindex, n+1);a31vec(l, m, kindex, j),a32vec(l, m, kindex, n+1),a33vec(l, m, kindex, j, n+1)];
the left hand side points to just 1 element, but you're trying to assign a vector to it. Matlab doesn't know what to do in this case. For us humans, it's like saying: this ONE number represents MANY numbers of different values. (No idea what that means...)
To fix, make A a cell array accessible by A{x,y,z,d},
EXAMPLE
A = cell(4,4,4,4);
A{x,y,z,d} = [1;2;3;4;5];
or ensure the right hand side matches the number of elements specified on the left hand side
EXAMPLE
A(x,y,z,[1:10]] = ones(1, 10) %Ex: 10 elements left hand = 10 elements on right
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!