MATLAB问题:在图的图块中引用变量的值

时间:2011-07-12 15:20:50

标签: matlab

  

可能重复:
  matlab - variable in plot title

我想引用m-file中定义的变量值,例如

让我们说我定义

d = 1;

在MATLAB代码中。我想用标题如

绘图
title('The Distribution of Some Variable when the Parameter is %d')

请告知。

2 个答案:

答案 0 :(得分:3)

title(sprintf('The Distribution of Some Variable when the Parameter is %d', d));

答案 1 :(得分:2)

title(['The Distribution of Some Variable when the Parameter is ' num2str(d)])

括号['concatenate ' 'strings']num2str()将数字(整数或小数)转换为字符串。