Assignment has more non-singleton rhs dimensions than non-singleton subscripts

2 次查看(过去 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

采纳的回答

OCDER
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 CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by