dynamically name function output

2 views (last 30 days)
fadams18
fadams18 on 15 Jul 2020
Edited: Stephen23 on 15 Jul 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 Comment
Stephen23
Stephen23 on 15 Jul 2020
Edited: Stephen23 on 15 Jul 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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!