matlab/octave 绘制网格

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);

在(aa, rr)的每一点,对于每个t都有一个值t^aa+rr^2,然后将这些值相加:

sum = (t1^aa+rr^2) + (t2^aa+rr^2) + ...

因此对于(aa,rr)的每一点,都有一个和数。你如何绘制该网格?

您可以 reshape t into the third dimension to generate all triples of aa, rr and t via implicit expansion, and then sum 在该维度上获得所需的结果:

t3 = reshape(t, 1, 1, []);
s = sum(t3.^aa + rr.^2, 3);
mesh(aa, rr, s)

在您的示例中,这会产生