Error: Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
Show older comments
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 Comment
Patty
on 10 Apr 2014
Answers (1)
Walter Roberson
on 10 Apr 2014
0 votes
See repmat()
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!