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

2 vues (au cours des 30 derniers jours)
Patty
Patty le 10 Avr 2014
Modifié(e) : Patty le 11 Avr 2014
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 commentaire
Patty
Patty le 10 Avr 2014
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.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 10 Avr 2014
See repmat()
  2 commentaires
Patty
Patty le 10 Avr 2014
Modifié(e) : Jan le 10 Avr 2014
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
Jan
Jan le 10 Avr 2014
I do not understand the notation.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by