Improper assignment error
14 次查看(过去 30 天)
显示 更早的评论
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!