Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Format 如何在MATLAB中将图例项强制为10的幂_Format_Matlab Figure_Legend - Fatal编程技术网

Format 如何在MATLAB中将图例项强制为10的幂

Format 如何在MATLAB中将图例项强制为10的幂,format,matlab-figure,legend,Format,Matlab Figure,Legend,这是一个扩展 我正在寻找一种方法,以强制在特定格式的图例条目。在下面的代码中,它们显示为 相反,我想让他们在10的权力。比如$10^{-1},10^{-2}$。 有办法做到这一点吗 MWE: sig=[0.1 0.01 0.001 0.0001 0.00001]; for j=1:length(sig) for x=1:10 Cost(j,x) = 2*x+j; end plot(1:10,Cost(j,:)); end legend(strcat('\sig

这是一个扩展

我正在寻找一种方法,以强制在特定格式的图例条目。在下面的代码中,它们显示为

相反,我想让他们在10的权力。比如$10^{-1},10^{-2}$。 有办法做到这一点吗

MWE:

sig=[0.1 0.01 0.001 0.0001 0.00001];
for j=1:length(sig)
    for x=1:10
       Cost(j,x) = 2*x+j;
    end 
plot(1:10,Cost(j,:));
end 
legend(strcat('\sigma^2_n=',num2str((sig)')));
set(h,'Interpreter','latex')

只需在
num2str
中的
log10
sig
,并在基础上加上前缀:

sig=[0.1 0.01 0.001 0.0001 0.00001];
for j=1:length(sig)
    for x=1:10
       Cost(j,x) = 2*x+j;
    end 
    hold('on');
    plot(1:10,Cost(j,:));
end 
h=legend(strcat('$\sigma^2_n = 10^{',num2str((log10(sig))'),'}$'));
set(h,'Interpreter','latex','fontsize',16)
hold('off');