[英]matlab/octave plot a mesh
t=0:0.01:2;
alpha=linspace(0, 1, 41);
r=linspace(0,1,41);
[aa,rr] = meshgrid(alpha,r);
At each point of (aa, rr), for each t there is a value t^aa+rr^2, then those values are summed up:在 (aa, rr) 的每个点,对于每个 t,都有一个值 t^aa+rr^2,然后将这些值相加:
sum = (t1^aa+rr^2) + (t2^aa+rr) + ...
Thus for each point of (aa,rr), there is a number of sum.因此,对于 (aa,rr) 的每个点,都有多个和。 How do you plot that mesh?你怎么plot那个网格?
You can reshape
t
into the third dimension to generate all triples of aa
, rr
and t
via implicit expansion , and then sum
over that dimension to get the desired result:您可以将t
reshape
为第三维,以通过隐式扩展生成aa
、 rr
和t
的所有三元组,然后对该维度sum
以获得所需的结果:
t3 = reshape(t, 1, 1, []);
s = sum(t3.^aa + rr.^2, 3);
mesh(aa, rr, s)
In your example, this produces在您的示例中,这会产生
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.