Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
Image 如何将png文件添加到matlab绘图中_Image_Matlab_Png - Fatal编程技术网

Image 如何将png文件添加到matlab绘图中

Image 如何将png文件添加到matlab绘图中,image,matlab,png,Image,Matlab,Png,如何将图像添加到我在matlab中绘制的绘图中?图片来自维基百科: title('addition: $1+1=2$', 'interpreter', 'latex') title('addition: $1+1=2$', 'interpreter', 'latex') 下面是我为我制作的情节设计的代码 x= 7:0.1:27; y= normpdf(x,17,exp(1)); title('Normal Distribution') hold on xlabel('x') ylabel(

如何将图像添加到我在matlab中绘制的绘图中?图片来自维基百科:

title('addition: $1+1=2$', 'interpreter', 'latex')

title('addition: $1+1=2$', 'interpreter', 'latex')
下面是我为我制作的情节设计的代码

x= 7:0.1:27;
y= normpdf(x,17,exp(1));
title('Normal Distribution')
hold on
xlabel('x')
ylabel('y')
plot(x,y)
title('addition: $1+1=2$', 'interpreter', 'latex')
我认为我需要使用的脚本应该是这样的,但它不起作用。有什么想法吗?谢谢

title('addition: $1+1=2$', 'interpreter', 'latex')

你想让图像本身显示在你的轴上吗?或者你想让图像中的方程以文本的形式显示在你的坐标轴上?因为要做第一件事,你需要:

title('addition: $1+1=2$', 'interpreter', 'latex')
x= 7:0.1:27;
y= normpdf(x,17,exp(1));
title('Normal Distribution')
hold on
xlabel('x')
ylabel('y')
plot(x,y)

img = imread('http://upload.wikimedia.org/math/7/3/a/73ad15f79b11af99bd2477ff3ffc5a35.png');
img = cat(3, img, img, img);
img = max(img(:)) - img;
img(img == max(img(:))) = 255;
hold on
xRange = [21 29];
yRange = [0.13 0.1];
imgHandle = image(linspace(xRange(1), xRange(2), size(img, 1)), ...
    linspace(yRange(1), yRange(2), size(img, 2)), img, 'Parent', gca);
hold off
它从给定的URL读取图像,调整图像,使其显示为黑白文本,然后将其作为对象添加到轴上

title('addition: $1+1=2$', 'interpreter', 'latex')
如果你只是想要方程式的文本,这是我认为你想要的,因为它更优雅,你可以这样做:

title('addition: $1+1=2$', 'interpreter', 'latex')
x= 7:0.1:27;
y= normpdf(x,17,exp(1));
title('Normal Distribution')
hold on
xlabel('x')
ylabel('y')
plot(x,y)

text(19, .145, '$f(x, \mu, \sigma) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^{2}}{2\sigma^{2}}}$', ...
    'interpreter', 'latex', 'FontSize', 14)

是的,你说得对,我试着用第二种方法。谢谢你的帮助-看起来很棒!如果你不介意的话,还有一个问题,我正在尝试将标准偏差添加到图表中,看起来我应该使用:s=std(X)s=std(X,flag)s=std(X,flag,dim),但我无法让它们中的任何一个正常工作。s=std(exp(1))是正确的语法吗?谢谢。如果希望
s
为等于0的单个值,这是正确的语法。如果你把代码提供给你所做的事情,你会更容易看出哪里出了问题。正如你所看到的,我正在强制使用平均值和标准偏差的行,看起来我应该能够更优雅地生成它们。x=7:0.1:27;y=normpdf(x,17,exp(1));标题(‘正态分布’)保存在xlabel(‘x’)ylabel(‘y’)绘图(x,y)文本(19.145,$f(x,\mu,\sigma)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^{2\sigma^{2}}$',…'解释器,'latex',FontSize',FontSize',14)x=[17,17];y=[0.1465];图(x,y)x=[14.22,14.22];y=[0.087];图(x,y)x=[19.78,19.78];y=[0.087];绘图(x,y)