dynamically name function output

2 vues (au cours des 30 derniers jours)
fadams18
fadams18 le 15 Juil 2020
Modifié(e) : Stephen23 le 15 Juil 2020
I would like to to dynamically name fuction output based on some inputs
Like: As my variable para.algo will be changing, is it possible automatically append it to the output SIR?
para.algo='RPIS';
[SIR, ~] = bss_eval_mix(W.', Htheo.');
% I dont want to manually write this,
% I would like it to be done automatically using value of algo
[SIR_RPIS, ~] = bss_eval_mix(W.', Htheo.');
  1 commentaire
Stephen23
Stephen23 le 15 Juil 2020
Modifié(e) : Stephen23 le 15 Juil 2020
That approach will force you into writing slow, complex, obfuscated code and makes accessing the data harder. Your code will break for any para.algo that contains characters that are not valid in MATLAB variable names.
Just use simple, efficient indexng to store both the function output and the algorithm name.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by