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:
working with functions

Subject: working with functions

From: Claribel

Date: 14 Aug, 2009 19:25:08

Message: 1 of 5

When I declare a function as follows "function umbral=UmbralOptimo2(imagen, filasImagen, columnasImagen, gradiente)" which is the way to send parameters from any point in the m-file.

Subject: working with functions

From: us

Date: 14 Aug, 2009 19:36:04

Message: 2 of 5

"Claribel " <clary1105@hotmail.com> wrote in message <h64dmk$6j4$1@fred.mathworks.com>...
> When I declare a function as follows "function umbral=UmbralOptimo2(imagen, filasImagen, columnasImagen, gradiente)" which is the way to send parameters from any point in the m-file.

what do you mean by ...send parameters from any point in the m-file...

us

Subject: working with functions

From: Ambarish Jash

Date: 14 Aug, 2009 19:47:04

Message: 3 of 5

"Claribel " <clary1105@hotmail.com> wrote in message <h64dmk$6j4$1@fred.mathworks.com>...
> When I declare a function as follows "function umbral=UmbralOptimo2(imagen, filasImagen, columnasImagen, gradiente)" which is the way to send parameters from any point in the m-file.

do u want to pass a parameter in the function "UmbralOptimo2" and return a value from that function.

Subject: working with functions

From: Claribel

Date: 14 Aug, 2009 21:55:19

Message: 4 of 5

I have this code and have this error ??? Input argument "imagen" is undefined.

Error in ==> UmbralOptimo at 11
if imagen (1,1)<(max(max(imagen))/2)

please help mefunction umbral=UmbralOptimo(imagen, filasImagen, columnasImagen)
I=imread('C:\Documents and Settings\Administrador\Mis documentos\matlab\placa.jpg');

numOscuros=0;
numClaros=0;
oscuros=0;
claros=0;
cont=0;
acum=0;

if imagen (1,1)<(max(max(imagen))/2)
    ultimoColor=1;
else
    ultimoColor=0;
end

for i=1:filasImagen
    if ultimoColor==0
        numClaros=numclaros+cont;
        cont=0;
        claros=claros+acum;
        acum=0;
    end
    
 for j=1:columnasImagen
     if gradiente(i,j)==0
         cont=cont+1;
         acum=acum+imagen(i,j);
     else
         if gradiente(i,j)==0
             numOscuros=numOscuros+cont;
             cont=1;
             oscuros=oscuros+acum;
             acum=imagen(i,j);
             ultimoColor=0;
         else
             numClaros=numClaros+cont;
             cont=1;
             claros=claros+acum;
             acum=imagen(i,j);
             ultimoColor=1;
         end
     end
 end
end

if ultimoColor==0
    numClaros=numClaros+cont;
    claros=claros+acum;
else
    numOscuros=numOscuros+cont;
    oscuros=oscuros+acum;
end

mediaClaros=claros/numClaros;
mediaOscuros=oscuros/numOscuros;
umbral=(mediaOscuros*numClaros+mediaClaros*numOscuros)/(numClaros+numOscuros);

[R,C]=size(I);
cropsize=[(R*0.25) (C*0.15) (C*0.6259) (R*0.6)];
Ic=imcrop(I,cropsize);
Id=double(Ic);
[R,C]=size(Ic);
umbral=UmbralOptimo(I,R,C);

Subject: working with functions

From: Bruno Luong

Date: 14 Aug, 2009 22:09:03

Message: 5 of 5

"Claribel " <clary1105@hotmail.com> wrote in message <h64mg7$2at$1@fred.mathworks.com>...
> I have this code and have this error ??? Input argument "imagen" is undefined.
>

How do you call your function? (i.e., what do you type when you want to use it?). It you only type the function name it is not enough.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f7-38012.html

Bruno

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