필터 지우기
필터 지우기

Error “Assignment has more non-singleton rhs dimensions than non-singleton subscripts”?

조회 수: 86 (최근 30일)
Why do I get the error “Assignment has more non-singleton rhs dimensions than non-singleton subscripts”?
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 2월 23일
pratik patel:
Please show us
size(X)
size(Y)
size(Z)
size(Vm)
I suspect that you have created either Z or Vm as global variables and failed to initialize them, which would leave them as empty, resulting in an empty right hand side.
Anshu Khare
Anshu Khare 2021년 1월 25일
bankans(i,:)=sum(bsxfun(@times, ft(i,:), H).^2,2);
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
i am getting this error.please help me

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 10월 23일
편집: MathWorks Support Team 2018년 11월 27일
In R2017b and earlier releases, this error occurs when you try to assign to a variable, but the indices of the left- and right-hand side of the assignment are incompatible. For example,
A(1) = [1 2 3];
throws this error because the size of the left-hand side is 1-by-1, but the size of the right-hand side is 1-by-3.
In R2018a and later, there is a new error message that replaces this error:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
For more information on matrix indexing, see:
  댓글 수: 3

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

CHANDRA
CHANDRA 2016년 8월 29일
what is the possible solution for this error
  댓글 수: 3
math man
math man 2017년 9월 6일
편집: Walter Roberson 2017년 9월 7일
I am getting the same error. But very curiously, if I go to the offending line (with a stop in the debugger), then press play, the error does not occur.
Here is some of the error/code:
Error in RealTime_SpreadOverWrite (line 11)
MainObject.MarketData(Row,SpreadBaseCol)=ViggedProbMat(Row,TextFind('SpreadBase1',RawMarketLabels))*SpreadSignMult;
The relevant values for the operation are all real-scalars which I can see are present when I put a stop before executing this line.
Puzzling- what code can I show to help solve this? Thanks!!
Greg Coyle
Greg Coyle 2017년 12월 24일
Great answer, Walter, thank you. I'd been checking length rather than size and all I needed to do was throw a transpose operator on one variable. Solved!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by