I have a function that takes a variable number of inputs, say myfun(x1,x2,x3,...).
Now if I have the inputs stored in a structure array S, I want to do something like
myfun(S.x1,S.x2,...). How do I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can first convert your structure to a cell array using STRUCT2CELL, and then use that to generate the list of multiple inputs.
Note that the order in which the fields in
Sare defined are the order in which the inputs are passed. To check that the fields are in the proper order, you can runfieldnamesonS, which returns a cell with field names corresponding to the values inC.