フィルターのクリア

Subscript indices must either be real positive integers or logicals. Error!

1 回表示 (過去 30 日間)
Lujain
Lujain 2014 年 2 月 19 日
コメント済み: Lujain 2014 年 2 月 19 日
I keep getting the same message no matter what I do, and I'm not sure in what line the error is.
My code:
for i=1:length(finalx(i)); row= ceil(finalx(i)*(10000+diffy)); col= ceil(finaly(i)*(10000+diffx)); widthless=3; widthmore=3; valuer(i)= sum(B((row-widthless):(row+widthmore),col)); end figure(7) plot(finaly*(10000+diffx), finalx*(10000+diffy-widthless),'*m',... finaly*(10000+diffx),finalx*(10000+diffy+widthmore),'.r')
for n=1:size(Eev,2); %size (Eev,2) will give the number of columns in matrix Eev nproton(1,n)=valuer(n)/interp1(Ecal,pslcal,Eev(n),'cubic'); end
figure(107);plot(Eev/1E6,nproton(1,:)); xlabel('Energy (MeV)');ylabel('nproton'); title 'nbr of proton vs. Energy (MeV)' text(1,40,'CP, 0.65 micron, 1200 V,PD signal=800mV, #1');

回答 (1 件)

Iain
Iain 2014 年 2 月 19 日
(row-widthless):(row+widthmore)
Thats probably giving you a negative (or zero) number which you're trying to use as an index.
max([row-widthless; 1]):(row+widthmore)
That should fix it, but you may have a similar problem when row+widthmore gets to be bigger than the maximum width in your array.
  1 件のコメント
Lujain
Lujain 2014 年 2 月 19 日
I changed it into: valuer(i)= sum(B(max([row-widthless;1]):(row+widthmore),col));
also, tried something like: valuer(i)= sum(B(max([row-widthless;1]):(row+widthmore))); and its still giving me the same message :/

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

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by