Variable user inputs (ie test numbers) to be used in a function

Hello,
I am trying to write a code to allow a user to enter multiple test numbers which will then be processed using a function that I have already written (euro).
The test numbers will be in the format CX 2013-05-30 XX (test facility code, date, test reference number).
What I would like to happen is the user enters a number of tests into command interface (or external UI) which is written into a matrix (so I can call each number in turn into the function). It would also be preferable that the number of user input are also recorded for the loops.
Anyone here have any advice?
Cheers
Matt

댓글 수: 2

Where are you stuck? What is the question?
I am looking for a way in MATLAB a user can type in a series of numbers in the command window ie:
C1 2013-06-01 01 C2 2013-06-01 02 C2 2013-06-01 03 C6 2013-06-01 01
What I then need to program to do is call each of then numbers in turn into a separate function (which I finishing now called EURO).
Trouble is I have no idea of how to have the code accept a varying number of inputs as there will be a different number of tests each day.

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

답변 (2개)

Iain
Iain 2013년 6월 6일
Don't use the command line unless you REALLY have to.
list = {};
more = true;
while more
string = input('enter your stuff');
if strcmpi(string,'some "end" code')
more = false;
else
... process and store string in the right fashion, and log it
end
end
I would suggest that you use excel instead. That way your user writes a spreadsheet logging stuff, and use "xlsread" in the way you want to get the data. Or read it from a text file.
David Sanchez
David Sanchez 2013년 6월 6일
nargin will do.
In your function, add conditions checking the number of input arguments (nargin).
doc nargin
will tell you what you need

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

질문:

2013년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by