Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.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
降低Matlab中生成三元曲面图的三维密度函数复杂度的思路_Matlab_Ternary_Surface_Density Plot - Fatal编程技术网

降低Matlab中生成三元曲面图的三维密度函数复杂度的思路

降低Matlab中生成三元曲面图的三维密度函数复杂度的思路,matlab,ternary,surface,density-plot,Matlab,Ternary,Surface,Density Plot,我有一个三维密度函数qx,y,z,我正试图在Matlab8.3.0.532 R2014a中绘制它 我的函数域从a开始,在b结束,具有均匀的间距ds。我想在三元曲面图上绘制密度,图中的每个维度表示给定点的x,y,z的比例。例如,如果我在q1,1,1的区域上有一个密度单位,在q17,17,17的区域上有另一个密度单位,在这两种情况下,x,y,z的比例相等,因此我在坐标1/3,1/3,1/3的三元曲面图上有两个密度单位。我有可以使用的代码。问题是比例点的数量随着域的大小呈指数增长。目前,我只能在单位间

我有一个三维密度函数qx,y,z,我正试图在Matlab8.3.0.532 R2014a中绘制它

我的函数域从a开始,在b结束,具有均匀的间距ds。我想在三元曲面图上绘制密度,图中的每个维度表示给定点的x,y,z的比例。例如,如果我在q1,1,1的区域上有一个密度单位,在q17,17,17的区域上有另一个密度单位,在这两种情况下,x,y,z的比例相等,因此我在坐标1/3,1/3,1/3的三元曲面图上有两个密度单位。我有可以使用的代码。问题是比例点的数量随着域的大小呈指数增长。目前,我只能在单位间距ds=1的每个维度上绘制一个大小为10的域。但是,我需要一个比这个尺寸大得多的域,每个维度都是100,比单位间距小得多,理想情况下只有0.1-这将导致网格上有100^3*1/0.1^3个点,这是Matlab无法处理的。有没有人知道如何通过3D比例存储密度函数以减少点数

我的工作代码和示例:

a = 0; % start of domain
b = 10; % end of domain
ds = 1; % spacing

[x, y, z] = ndgrid((a:ds:b)); % generate 3D independent variables
n = size(x);

q = zeros(n); % generate 3D dependent variable with some norm distributed density
for i = 1:n(1)
    for j = 1:n(2)
        for k = 1:n(2)
            q(i,j,k) = exp(-(((x(i,j,k) - 10)^2 + (y(i,j,k) - 10)^2 + (z(i,j,k) - 10)^2) / 20));
        end
    end
end

Total = x + y + z; % calculate the total of x,y,z at every point in the domain
x = x ./ Total; % find the proportion of x at every point in the domain
y = y ./ Total; % find the proportion of y at every point in the domain
z = z ./ Total; % find the proportion of z at every point in the domain
x(isnan(x)) = 0; % set coordinate (0,0,0) to 0
y(isnan(y)) = 0; % set coordinate (0,0,0) to 0
z(isnan(z)) = 0; % set coordinate (0,0,0) to 0

xP = reshape(x,[1, numel(x)]); % create a vector of the proportions of x
yP = reshape(y,[1, numel(y)]); % create a vector of the proportions of y
zP = reshape(z,[1, numel(z)]); % create a vector of the proportions of z

q = reshape(q,[1, numel(q)]);  % create a vector of the dependent variable q

ternsurf(xP, yP, q);  % plot the ternary surface of q against proportions
shading(gca, 'interp');
colorbar
view(2)
我相信你在最里面的循环中指的是n3。以下是一些提示:

1.松开线圈:

q = exp(- ((x - 10).^2 + (y - 10).^2 + (z - 10).^2) / 20);
2.松开整形:

xP = x(:); yP = y(:); zP = z(:);
3检查总计一次,而不是对x、y、z进行三次检查:


我刚认出你的名字。。是乔纳森

离散化方法可能取决于绘图的使用,也许从这个角度澄清问题是有意义的。 总的来说,您可能正在与内存不足错误作斗争,这里介绍了一些相关的技巧。当然,它们只能工作到一定大小的数组


一个更通用的解决方案是将阵列的一部分保存在硬盘上,这会使处理速度变慢,但会起作用。例如,您可以使用特定于刻度的NgrID定义多个q函数,例如ngridOrder0=[0:10:100]、ngridOrder10=[1:1:9]、ngridOrder11=[11:1:19]等,并编写一个访问器函数,该函数将根据正在查看的绘图部分加载/保存相关网格和q函数

嘿,乔纳森,谢谢,所有的好提示!有没有关于随后合并我的“比例空间”以减少点数的想法?我认为这实际上是一道有趣的数学题!我可以考虑如何使用for循环和许多if-else语句,但这将非常笨拙和缓慢。干杯我在OP中没有看到任何关于binning的内容。如果有子问题,您应该包括一个清晰的描述,可能是一个虚拟代码,该代码不运行,但看起来像您试图实现的:
Total = x + y + z; % calculate the total of x,y,z at every point in the domain
Total( abs(Total) < eps ) = 1;
x = x ./ Total; % find the proportion of x at every point in the domain
y = y ./ Total; % find the proportion of y at every point in the domain
z = z ./ Total; % find the proportion of z at every point in the domain