Improper assignment error

14 visualizaciones (últimos 30 días)
Bhagat
Bhagat el 4 de Mzo. de 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 comentario
Jan
Jan el 4 de Mzo. de 2011
Please post formatted code, because it is much easier to read.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 4 de Mzo. de 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.

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by