Contain outputs of function in one table(?)
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Christian
am 4 Mai 2015
Beantwortet: Nobel Mondal
am 5 Mai 2015
Hi there,
I wrote a function, which gives out 10 numbers as a result. Right now, I am containing the outputs like this
[a,b,c,d,e,f] = function(Inputvariables) ... which is a bit annoying
Is there a better way to cope with a function that has a lot of output variables?
Any help is much appreciated! Christian
0 Kommentare
Akzeptierte Antwort
Nobel Mondal
am 5 Mai 2015
1. If your output variables all have equal number of rows, you indeed can use a 'table' datatype.
doc table
2. Otherwise, you could create a struct and define the output parameters as fields of that. This would require declaring single output variable at the function definition.
3. You could also store them in a cell-array and pass as the single output argument. However, this would require some indexing wrt the variables. So I might turn up saving the parameter names along.
function cellOutput = myFunc(inputArgs)
% Do something and collect outputs a, b, c
cellOutput{1,1} = 'a';
cellOutput{1,2} = a;
% and so on...
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!