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

조회 수: 2 (최근 30일)
Patty
Patty 2014년 4월 10일
편집: Patty 2014년 4월 11일
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