Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
??? Subscript indices must either be real positive integers or logicals.

Subject: ??? Subscript indices must either be real positive integers or logicals.

From: Justin Hay

Date: 5 Nov, 2012 03:29:10

Message: 1 of 2

Hey guys,
My program was working fine, until today when I run it and it displays this error:
??? Subscript indices must either be real positive integers or logicals.

What does it mean? And please suggest what I can do to my program? My project grading is tomorrow! Pls help!

Program:
darkCarValue = 60;
darkCar = rgb2gray(read(trafficObj, 1));
maskDarkCar = darkCar;
noDarkCar = imextendedmax(maskDarkCar,darkCarValue);
figure, imshow(darkCar)
figure, imshow(noDarkCar)
sedisk = strel('disk',1);
noSmallStructures = imopen(noDarkCar, sedisk);
figure, imshow(noSmallStructures)

nframes = get(trafficObj, 'NumberOfFrames');
I = read(trafficObj, 1);
taggedCars = zeros([size(I,1) size(I,2) 3 nframes], class(I));
 
for k = 1 : nframes
singleFrame = read(trafficObj, k);
I = rgb2gray(singleFrame);
        noDarkCars = imextendedmax(I, darkCarValue);
noSmallStructures = imopen(noDarkCars, sedisk);
noSmallStructures = bwareaopen(noSmallStructures, 150);
L = bwlabel(noSmallStructures);
taggedCars(:,:,:,k) = singleFrame;

if any(L(:))
stats = regionprops(L, {'centroid','area'});
areaArray = [stats.Area];
[junk,idx] = max(areaArray);
c = stats(idx).Centroid;
c = floor(fliplr(c));
width = 2;
row = c(1)-width:c(1)+width;
col = c(2)-width:c(2)+width;
taggedCars(row,col,1,k) = 255;
taggedCars(row,col,2,k) = 0;
taggedCars(row,col,3,k) = 0;
end
end

Subject: ??? Subscript indices must either be real positive integers or

From: Nasser M. Abbasi

Date: 5 Nov, 2012 03:51:43

Message: 2 of 2

On 11/4/2012 9:29 PM, Justin Hay wrote:
> Hey guys,
> My program was working fine, until today when I run it and it displays this error:
> ??? Subscript indices must either be real positive integers or logicals.
>
> What does it mean?

hi,

It means the index must be positive integer or logical. Nothing else.


>And please suggest what I can do to my program? My project grading is tomorrow! Pls help!
>

Have you tried using the debugger? set break on error, and run it. It will stop at
the line where the error is. You'll see it on the screen.

hth

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us