Error: Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts

2 次查看(过去 30 天)
Hi, I'm trying to make a code for a Linear Programming model. Using linprog tool. The for loop presented is one of the constraints of the system.
The ERROR is given by the first calculation of xtemp2 , and it says that _ "Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts" _ .
My intention is that for every loop of kk, the xtemp2(:,F(tt):N(tt),kk) which has 3 dimensions, counts all rows and put it equal to r(:,kk) . In this case, rows in both represent the same (total_product).
I don't understand what I'm doing wrong. I know it might be a simple thing, but I'm new with MATLAB, so it is complicated for me to see.
Thanks for any help!
if true
% code
Line=2
total_product=2
macro_period=2
micro_period=4
F = [1;3]
L = [2;4]
down_time = [3 5;3 5]
cap = [200 150;500 400]
r = [2 3;1 2]
st = [0 2 ;2 0]
st(:,:,2) = [0 1;1 0]
for tt = 1:macro_period
for kk = 1:Line
xtemp2 = clearer2
xtemp2(:,F(tt):L(tt),kk) = r(:,kk) * * | |*%%This Line has the ERROR %%*| | * *
xtemp3 =clearer3
xtemp3(:,:,kk,F(tt):L(tt))= st(:,:,kk)
xtemp = sparse([clearer12;xtemp2(:);xtemp3(:)])
Aineq(counter,:) = xtemp
bineq(counter) = cap(kk,tt)-down_time(kk,tt)
counter = counter + 1
end
end
end
  1 个评论
Patty
Patty 2014-4-10
For example, this are the two matrices by separate.
if true
% code
r(:,kk)
ans =
2
1
xtemp2(:,F(tt):L(tt),kk)
ans =
0 0
0 0
end
What I want to do, is that xtemp2 in this loop looks like:
if true
2 2
1 1
How can I do that? Because What I have now, is not working because the error.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2014-4-10
See repmat()
  2 个评论
Patty
Patty 2014-4-10
编辑:Jan 2014-4-10
Tried, but is not working. To make it more clear I want that the matrix has these values at the end of each loop as indicated.
xtemp2
for tt = 1
for kk = 1
n1 n2 n3 n4
j1 2 2 0 0
j2 1 1 0 0
kk = 2
n1 n2 n3 n4
j1 3 3 0 0
j2 2 2 0 0
for tt = 2
for kk = 1
n1 n2 n3 n4
j1 0 0 2 2
j2 0 0 1 1
kk = 2
n1 n2 n3 n4
j1 0 0 3 3
j2 0 0 2 2

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by