naming matrix with a specific pattern
Mostra commenti meno recenti
I want to make a function that uses input a positive integer, and the number of outputs depends on the input. For example, if I put 5 as an input, the outputs will be five matrix: named from a_1 to a_5. If I put an input of 50, the outputs will be from a_1 to a_50. It will be very time consuming if I make a code of function that specifies all the names of outputs. Thus, I would rather give a specific pattern for the outputs. Is it possible in Matlab?
2 Commenti
Related question by the same OP:
Risposta accettata
Più risposte (1)
dpb
il 30 Set 2016
1 voto
Possible but a_very_BAD_idea(tm) indeed. How are you going to write the consumer of this function if you have 50 separate outputs???!!! You're back to the same coding problem every time you try to use it, not just when writing it.
Use either an array that the user can query as to size or at worst a structure w/ named fields that can be programmatically iterated over. The latter is, in my opinion, only a small step above the first in a design, but perhaps with an explanation of why you want to do this and how it would be useful to have so many individual variables you might convince somebody...
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!