how to change grid option(size of grid & granularity)
14 次查看(过去 30 天)
显示 更早的评论
i have this mask.and display that by meshc function?
z=[ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000;
-0.0005 -0.0001 0.0000 0.0000 0.0000 0.0000;
0.0038 0.0001 -0.0005 -0.0000 0.0000 0.0000;
0.0074 0.0066 0.0027 -0.0003 0.0000 0.0000;
0.0054 0.0067 0.0078 0.0011 -0.0001 0.0000;
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000];
meshc(z)
how to change grid option like this image :
0 个评论
采纳的回答
Star Strider
2015-12-6
编辑:Star Strider
2015-12-6
EDIT — To illustrate (literally):
og = [1:6]; % Original Grid (Vector)
[X,Y] = meshgrid(og); % Original Grid (Matrices)
qg = linspace(min(og), max(og), 25); % Query Grid (Vector)
[Xq,Yq] = meshgrid(qg); % Query Grid (Matrices)
zq = interp2(X,Y,z,Xq,Yq, 'spline'); % Interpolated ‘z’
figure(1)
meshc(Xq, Yq, zq)
grid on
Explore the options (grid size, interpolation method, etc.) presented in the interp2 documentation.
6 个评论
Star Strider
2015-12-6
First — The ‘6’ in the original ‘x’ vector was used to create the (6x6) [X,Y] matrices necessary to provide an original independent variable reference for interp2, since ‘z’ is (6x6). The ‘25’ is simply the arbitrary length of the vector I used to create the [Xq,Yq] ‘query’ matrices for interp2. Any length will work, providing it produces a readable plot.
Second — If you want the interpolation matrices to be (15x16), create vectors to use in meshgrid to produce the appropriate ‘query’ matrices.
Third — Thank you, Image Analyst!
The code to produce a (15x16) interpolated grid:
og = [1:6]; % Original Grid (Vector)
[X,Y] = meshgrid(og); % Original Grid (Matrices)
qgx = linspace(min(og), max(og), 16); % Query Grid (X-Vector) (1x16)
qgy = linspace(min(og), max(og), 15); % Query Grid (Y-Vector) (1x15)
[Xq,Yq] = meshgrid(qgx, qgy); % Query Grid (Matrices) (15x16)
zq = interp2(X,Y,z,Xq,Yq, 'spline'); % Interpolated ‘z’
figure(1)
meshc(Xq, Yq, zq)
grid on
You can change the ‘qgx’ (query grid x) vector and ‘qgy’ vector to be anything you want. Experiment with other options available in the interp2 function.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!