Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Lujain
Lujain am 19 Feb. 2014
Kommentiert: Lujain am 19 Feb. 2014
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');

Antworten (1)

Iain
Iain am 19 Feb. 2014
(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 Kommentar
Lujain
Lujain am 19 Feb. 2014
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 :/

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by