How to remove this error Improper assignment with rectangular empty matrix.

1 回表示 (過去 30 日間)
Amit
Amit 2012 年 2 月 28 日
While running this file I m getting an error as ??? Improper assignment with rectangular empty matrix. I dont know what wrong I m doing? va is vector and d_va may have some nan value also.
b=floor(100-100*min(sp)); d_va=zeros(1,b);
for a=1:b
m=(100-a)/100;
xa=find(m-0.001 <= sp & sp <= m+0.001, 1, 'last' );
m2=m-(0.05*m/100);
xb =find(m2-0.001<=sp & sp<=m2+0.001, 1, 'last' );
va1=va(xa);
va2=va(xb);
d_va(a)=(va1-va2)*100/va1; % This line shows an error,??? Improper assignment with rectangular empty matrix.
end
end
  1 件のコメント
Andrew Newell
Andrew Newell 2012 年 2 月 28 日
It is easier to diagnose your code if you provide a complete working example (with values for the variables b, sp, etc.)

サインインしてコメントする。

回答 (1 件)

Andrew Newell
Andrew Newell 2012 年 2 月 28 日
I can't reproduce your exact error message, but it is probably occurring because either va or vb are empty (there weren't any values of sp in the correct range). What you do depends on whether this is an error or it is o.k. If the latter, you could try something like this:
dva = zeros(b,1); % You should initialize dva
...
if any(va1) & val~=0 & any(va2)
dva(a)=(va1-va2)*100/va1;
end
  3 件のコメント
Tom
Tom 2012 年 2 月 28 日
you mentioned 'dv(a)', whereas in the code it is 'dva(a)'- have you got variables called 'dv' and 'dva' ?
Amit
Amit 2012 年 2 月 29 日
yeah I put the dv =zeros(1,b);
dva=zeros(1,b)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by