how to change grid option(size of grid & granularity)
조회 수: 16 (최근 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!