how can I make grids on an inclined surface?
3 views (last 30 days)
Show older comments
Hello All
I want to make grids on an inclined surface and store all the X, Y and Zs in a matfile. I wrote the following codes but when I plot, it is not a surface. how can I do this
Thank you
clear all
clc
strike_min=-200;
strike_max=200;
ddip_min=0;
ddip_max=300/cosd(10);
z_min=0;
z_max=300*tand(10);
interval=20;
strike=strike_min:interval:strike_max;
downdip=ddip_min:interval/cosd(10):ddip_max;
depth=z_min:interval:z_max;
[X,Y,Z] = meshgrid(strike, downdip,depth);
alongStrike = X(:);
downDip = Y(:);
Depth=Z(:);
% plot(alongStrike,downDip,'b.');
plot3(alongStrike,downDip,Depth,'b.');
axis ij
xlabel('along strike'); % // Label the X and Y axes
ylabel('downdip');
title('base for slipvelocity');
box on
2 Comments
Walter Roberson
on 24 Jun 2018
This does not create an inclined grid.
I recommend that you first create a non-inclined grid, and then rotate the points using a transformation matrix.
Answers (1)
Walter Roberson
on 24 Jun 2018
N = 20;
[X, Y, Z] = ndgrid(1:N);
tform = makehgtform('scale', [400/N, 300/cosd(10)/N, 300*tand(10)], 'translate', [-200, 0, 0], 'xrotate', -10*pi/180);
XYZ = [X(:), Y(:), Z(:), zeros(numel(X),1)];
XYZt = XYZ * tform;
Xt = reshape(XYZt(:,1), size(X));
Yt = reshape(XYZt(:,2), size(Y));
Zt = reshape(XYZt(:,3), size(Z));
scatter3(Xt(:), Yt(:), Zt(:))
xlabel('strike')
ylabel('dip')
zlabel('depth')
set(gca, 'zdir', 'reverse')
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!