Improper assignment error

조회 수: 13 (최근 30일)
Bhagat
Bhagat 2011년 3월 4일
I wrote the following code: w=10:2:30; b=(-4*w-4); c=(-(w+1).*(-4*w-4)+w+6); d=-2*(w+1).^2-(w+1).^3; f = zeros(1,length(w));
for ii = 1:numel(w) g = roots([b(ii),c(ii),d(ii)]); f(ii) = g(g<1); end
ptr=2./(1+w); u=2./(6+w); l=(u.*(1-ptr.*f).^3)./3; plot(w,l); xlabel('w - contention window size'); ylabel('Normalized throughput'); title('O/p for the case of simple routing'); grid;
------x-------
??? Improper assignment with rectangular empty matrix.
Error in ==> tstsr at 9 f(ii) = g(g<1); ------x------
How to correct this error ?
  댓글 수: 1
Jan
Jan 2011년 3월 4일
Please post formatted code, because it is much easier to read.

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

답변 (1개)

Jan
Jan 2011년 3월 4일
In this line:
f(ii) = g(g<1)
the right hand side is a [1 x 0] vector, while the left hand side expects a scalar. Use the debugger to inspect your code:
dbstop if error
Then dispaly the value of "g(g<1)" in the command window, when the program stops automatically at reaching the error.

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by