相关疑难解决方法(0)

在Matlab中打印变量名

我在Matlab中有一个函数,里面有一些变量.我需要打印出variable_names(如果是异常等).我知道inputname函数,但它只适用于input_arguments.

mat = [ 1 2 ; 3 4 ] ;

% disp(['Error in var: ' ??(a)])
% desired ouput: Error in var: mat     (and NOT 1 2 ; 3 4!)
Run Code Online (Sandbox Code Playgroud)

谢谢!

matlab naming-conventions string-formatting

14
推荐指数
3
解决办法
2万
查看次数

图例中变量的名称,matlab

我想在matlab中的图例中使用变量的名称.这可能吗?

我的例子是:

function example(x1)
    figure;
    plot(x1.time, x1.value);
    legend(x1);
end
Run Code Online (Sandbox Code Playgroud)

现在我想调用我的函数:

>> example(myvariable)
Run Code Online (Sandbox Code Playgroud)

我的传奇应该是这样的:

---------------
| -- myvariable |
---------------
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

matlab legend legend-properties matlab-figure

0
推荐指数
1
解决办法
1273
查看次数