[英]Subscripted assignment dimension mismatch
This has been a fairly trivial error for me in the past, but I am not seeing it here. 在过去,这对我来说是一个相当微不足道的错误,但是我在这里看不到它。
>> rmatrix = zeros(size(Rx,1), size(Rx,2));
for k = 1:size(Rx,1)
for l = 1:size(Rx,2)
rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2];
end
end
??? Subscripted assignment dimension mismatch.
rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2];
you're trying to assign a 1x2
matrix to a 1x1
matrix 您正在尝试将
1x2
矩阵分配给1x1
矩阵
perhaps you intended to do the following: 也许您打算执行以下操作:
rmatrix = zeros(size(Rx,1), size(Rx,2),2);
for k = 1:size(Rx,1)
for l = 1:size(Rx,2)
rmatrix(k,l,:) = [Rx(k,l).^2, (Ry(k,l)).^2];
end
end
//edit: which you could do a lot easier with: // edit:您可以通过以下操作轻松完成:
rmatrix = cat(3,Rx,Ry).^2
>> rmatrix = zeros(size(Rx,1), size(Rx,2));
for k = 1:size(Rx,1)
for l = 1:size(Rx,2)
rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2]; % CHECK THIS LINE
end
end
??? Subscripted assignment dimension mismatch.
The problem is this surely?? 问题是这肯定吗?
rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2];
You assign a vector to a scalar element of your array. 您可以将向量分配给数组的标量元素。 Is this not the problem?
这不是问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.