我想引用m-file中定义的变量值,例如
让我们说我定义
d = 1;
在MATLAB代码中。我想用标题如
绘图title('The Distribution of Some Variable when the Parameter is %d')
请告知。
答案 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()
将数字(整数或小数)转换为字符串。