-3

[enter image description here][1]im working on my project and in the mean while i created a loop where i always get the error .I would appreciate if someone looks into this issue and help me out to complete my project

Subscript indices must either be real positive integers or logicals.

Error in testmatrix (line 10) c(i,j) = 0;

clc;
clear all;   
a=imread('test1.tif');
[ap,bq]=size(a);
for q=1:320;
    for p=1:240;
        if a(ap,bq)==i && a(ap,bq+1)==j
            c(i,j)=1;
        else
            c(i,j)=0;
        end         
    end 
end

c(i,j) must be equal to 1 of a(ap,bq)=0 and a(ap,bq+1) must be 1 else c(i,j) must be zero. But the above mentioned is the error i get. I cant the condition above.How do i overcome the error.

varshini
  • 1
  • 1

1 Answers1

-1

As you can see, you set the value 0 for variables i and j. Indexing in MATLAB goes from 1.

Zoltán Csáti
  • 679
  • 5
  • 17