MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   网格(...)问题Matlab (https://www.labfans.com/bbs/showthread.php?t=26658)

poster 2019-12-14 20:46

网格(...)问题Matlab
 
我有这段代码,它可以正确绘制高斯模型,但是当尝试用网格绘制它时,我有一个错误,请告诉我如何纠正它:

covariances = [1 0; 0 1]; Mean = [1 0] mycolor = 'r'; icov = inv(covariances); det_cov = det(covariances); const = 1/(2*pi*sqrt(det_cov)); xx = linspace(Mean(1)-3*sqrt(covariances(1,1)),Mean(1)+3*sqrt(covariances(1,1))); yy = linspace(Mean(2)-3*sqrt(covariances(2,2)),Mean(2)+3*sqrt(covariances(2,2))); [xy] = meshgrid(xx,yy); mx=x-Mean(1); my = y-Mean(2); z=const*exp(-0.5*(icov(1,1)*mx.^2+icov(2,1)*mx.*my +icov(2,1)*my.*mx+icov(2,2)*my.^2)); figure(1) contour(x,y,z,mycolor); figure(2) mesh(x,y,z,mycolor); 我遇到了mesh(x,y,z,mycolor);

??? Error using ==> mesh at 72 Property value pairs expected.

[B]回答:[/B]

由于mycolor是一个字符串,而不是与x , y和z大小相同的颜色值矩阵,因此[URL="http://www.mathworks.com/help/techdoc/ref/mesh.html"]MESH[/URL]希望将其作为[URL="http://www.mathworks.com/help/techdoc/ref/surfaceplotproperties.html"]属性/值对输入[/URL] ,如下所示:

mesh(x,y,z,'EdgeColor',mycolor); 我建议您查阅文档以获取有关为[URL="http://www.mathworks.com/help/techdoc/visualize/f0-18164.html"]网格和表面图着色的[/URL]更多信息。



[url=https://stackoverflow.com/questions/5354769]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:23

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.