How do I retrieve the names of function parameters in matlab?

前端 未结 6 1236
面向向阳花
面向向阳花 2020-12-01 12:18

Aside from parsing the function file, is there a way to get the names of the input and output arguments to a function in matlab?

For example, given the following fun

6条回答
  •  不思量自难忘°
    2020-12-01 13:13

    Have you considered using map containers?

    You can write your functions along these lines . . .

    function [outMAP] = divide(inMAP)
         outMAP = containers.Map();
         outMAP('value') = floor(inMAP('left') / inMAP('right'));
         outMAP('remain') = inMAP('left') / inMAP('right') - outMAP('value');
    end
    

    ...and call them like this ...

    inMAP  = containers.Map({'left', 'right'}, {4, 5});
    outMAP = divide(inMAP);
    

    ...and then simply examine tha variable names using the following syntax...

    >> keys(inMAP)
    
    ans = 
    
        'left'    'right'
    

提交回复
热议问题