Argument Question?

I have a homework assignment that says, "Your function will receive the name of the input file as an argument." I'm just a little confused on what that means. Does it means it will be something along the lines of:
function HW = load('data1.txt')

 Respuesta aceptada

Sarah Wait Zaranek
Sarah Wait Zaranek el 29 de Abr. de 2011

0 votos

I think this is what they meant -
In the function file:
function outputVar = myfunction(inputVar)
% write the rest of the program here, using inputVar as you would a string
When you call the function you give it a string:
thisoutput = myfunction('data1.txt')

4 comentarios

Walter Roberson
Walter Roberson el 29 de Abr. de 2011
"input" is a MATLAB function name, so it is better to avoid using that particular variable name.
Matt Fig
Matt Fig el 29 de Abr. de 2011
And don't name your function LOAD or you will mask the built-in LOAD function.
Cote
Cote el 29 de Abr. de 2011
Thanks a ton!
Sarah Wait Zaranek
Sarah Wait Zaranek el 29 de Abr. de 2011
Walter, yes I was doing that for clarity. I will change it to inputvar and outputvar.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink en Centro de ayuda y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by