필터 지우기
필터 지우기

how to change grid option(size of grid & granularity)

조회 수: 9 (최근 30일)
fred bnm
fred bnm 2015년 12월 6일
댓글: Star Strider 2015년 12월 6일
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 :

채택된 답변

Star Strider
Star Strider 2015년 12월 6일
편집: Star Strider 2015년 12월 6일
Since you have gridded data, the interp2 function is perfect for what you want to do.
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
fred bnm
fred bnm 2015년 12월 6일
@star strider how to set parameter for matrix [15*16] ?
Star Strider
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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by