Improper assignment error

9 views (last 30 days)
Bhagat
Bhagat on 4 Mar 2011
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 Comment
Jan
Jan on 4 Mar 2011
Please post formatted code, because it is much easier to read.

Sign in to comment.

Answers (1)

Jan
Jan on 4 Mar 2011
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.

Categories

Find more on Debugging and Analysis 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!