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')

 채택된 답변

Sarah Wait Zaranek
Sarah Wait Zaranek 2011년 4월 29일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by