Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

programm error

0 views
Skip to first unread message

Gaurav Verma

unread,
Feb 13, 2012, 1:12:11 PM2/13/12
to
Hello sir,
i m doing one program shows some error.
can u help me?

Ie=imread('imd.jpg');
[x,y]=size(Ie);
h=x/2;
for i=1:x
for j=1:y
if Ie(i,j)==0
Ic(i,j)=0;
else if ((Ie(i+1,j-1)==1)& (Ie(i+1,j+1)==1))
Ic(i,j)=0;
else if (((Ie(i+1,j-1)==1)&(i<=h))|(Ie(i+1,j+1)==1) & (i>h))
Ic(i,j)=1;
else if (((Ie(i+1,j+1)==1) & i<=h)|| (Ie(i+1,j-1)==1)& (i>h))
Ic(i,j)=-1;
end %if
end %for
end

dpb

unread,
Feb 13, 2012, 5:07:18 PM2/13/12
to
On 2/13/2012 12:12 PM, Gaurav Verma wrote:
> Hello sir,
> i m doing one program shows some error.
> can u help me?
...

And how are we to know what error that might be if you provide no clues...

--

Steven_Lord

unread,
Feb 13, 2012, 5:14:02 PM2/13/12
to


"Gaurav Verma" <gkum...@gmail.com> wrote in message
news:jhbjpr$pho$1...@newscl01ah.mathworks.com...
> Hello sir,
> i m doing one program shows some error.
> can u help me?
>
> Ie=imread('imd.jpg'); [x,y]=size(Ie);
> h=x/2;
> for i=1:x
> for j=1:y
> if Ie(i,j)==0 Ic(i,j)=0;
> else if ((Ie(i+1,j-1)==1)& (Ie(i+1,j+1)==1))

There's no such thing as the 0th column of a matrix in MATLAB. The first
row/column/element/etc. of an array is row/column/element/etc. 1.

*snip*

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Roger Stafford

unread,
Feb 14, 2012, 10:04:44 AM2/14/12
to
"Gaurav Verma" wrote in message <jhbjpr$pho$1...@newscl01ah.mathworks.com>...
- - - - - - - - -
I see at least two problems here. First, in the for-loops the index j-1 can equal zero and the indices i+1 and j+1 can be above the range of Ic which will produce an error message. Second, the 'elseif' should not have a space between the 'else' and the 'if'. As it stands it does not have enough end's and that will create a parsing error message when the program is compiled.

Roger Stafford
0 new messages