필터 지우기
필터 지우기

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 CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by