dynamically name function output

조회 수: 4 (최근 30일)
fadams18
fadams18 2020년 7월 15일
편집: Stephen23 2020년 7월 15일
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
Stephen23
Stephen23 2020년 7월 15일
편집: Stephen23 2020년 7월 15일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by