Passing multiple, similar tables as inputs and outputs.
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have a script EDL_Main which calls other functions and scripts, and part of it reads Excel tables into MATLAB tables such as SystemDRTBL. Other functions (such as EDL_CalcSubSpecs), following the reading and definition of tables, require multiple tables, and I'd like to return multiple tables as outputs if possible.
I imagine that it is possible to pass multiple MATLAB tables as input arguments to functions and scripts (correct me if I'm wrong), but is it possible for a function to return multiple MATLAB tables as outputs?
If not possible, could you please offer alternative concepts to achieve this? I'm gathering subsystem requirements MATLAB tables (Variables {'Description' 'Symbol' 'Value' 'Units' 'Dim'}) to perform calculations. I would like to pass these resultant calculations to several different calculations MATLAB tables (such as SystemCRTBL, with equivalent Variables) and return these tables as outputs of the function (such as EDL_CalcSubSpecs)
Thanks
0 commentaires
Réponses (1)
Image Analyst
le 26 Avr 2015
You can use readtable(filename) to read in the Excel file. Use the 'Sheet' and 'Range' options if you need to specify where to read the table from in Excel.
A table is a variable just like any other, like double, integer, cell array, structure, etc. Tables are sort of like cell arrays but the columns of a table must all have the same data type, though different columns can have different data types, like strings in column 1 and doubles in column 2. I think tables are somewhat easier to use than cell arrays, once you learn the syntax for dealing with them. Look up the "table" function in the help to see some syntax examples. Of course you can send table variables into functions and get table variables returned from functions just like any other variable.
2 commentaires
Image Analyst
le 27 Avr 2015
You could do either of those. You could combine multiple tables into a cell array, fields of a single structure, of the same field name of an array of structures. There is a lot of flexibility around how you can organize all your tables into a single variable - it just depends on what you think is easiest to deal with.
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!