Passing multiple, similar tables as inputs and outputs.

11 vues (au cours des 30 derniers jours)
N/A
N/A le 26 Avr 2015
Commenté : Image Analyst le 27 Avr 2015
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

Réponses (1)

Image Analyst
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
N/A
N/A le 26 Avr 2015
Thank you for your reply Image Analyst. My Excel table reading code is perfected I believe, but I'm uncertain of how to 'pack up' multiple tables together.
Can I make a cell array of tables? What about a struct array of tables? How can I reference a single table packed inside of another variable/table/cell?
I've read through xlsread and table and others many times to get as far as I have, but so far I have yet to see a single instance of someone using:
[Table3, Table4] = function(Table1, Table2)
Thank you for your time and wisdom.
Image Analyst
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.

Connectez-vous pour commenter.

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!

Translated by