|
1.函数meshgrid对y中行的每一行复制x,同样也对x中列的每一列复制y。这种方向与前面语句相一致,即y向下改变其列,而x横跨改变其行。
2.
x=??? % statement defining vector of x-axis values
y=??? % statement defining vector of y-axis values
nx=length(x); % length of x is no. of rows in Z
ny=length(y); % length of y is no. of columns in Z
Z=zeros(nx,ny); % initialize Z matrix for speed
for r=1:nx
{preliminary commands}
Z(r,:)={a function of y and x(r) defining r-th row of Z}
end
3.
x=??? % statement defining vector of x-axis values
y=??? % statement defining vector of y-axis values
nx=length(x); % length of x is no. of rows in Z
ny=length(y); % length of y is no. of columns in Z
Z=zeros(nx,ny); % initialize Z matrix for speed
for r=1:nx
for c=1:ny
{preliminary commands}
Z(r,c)={a function of y(c) and x(r) defining Z(r,c)}
end
end
4.在有些情况下,两个变量的标量函数的值,如z=f(x,y),不能简单地算出。这是因为要么x和y的值是非均匀间隔的(最坏时是随机分布),要么是用了不同的坐标系,比如非长方形的网格。出现这些情况时,MATLAB中的函数griddata就用来产生经插值后的均匀间隔数据以作图。首先考虑前面的例子。假设要求较高的分辨率,但我们不想重新计算函数来得到新值。
GMT+8, 2024-5-20 09:07 , Processed in 0.028394 second(s), 17 queries , Gzip On.
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.