how to change grid option(size of grid & granularity)
16 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 6 Dec 2015
Edited: Star Strider
on 6 Dec 2015
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 Comments
Star Strider
on 6 Dec 2015
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.
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!