Help with the surf function

I am trying to create a surface plot of a matrix I created, but I need to make lattitude and longitue in to 180x360 matrices as well in order for the function to work. My code is below:
%Plot Slopematrix
addpath('C:\Users\Falon Treis\Documents\MATLAB\CE1_2C_slopematrix.mat');
%addpath('C:\Users\Falon Treis\Documents\MATLAB\CE2_2C_slopematrix.mat');
load('CE1_2C_slopematrix.mat')
k = 1:180; %lat make have 180x 360 matrix
m = 1:360; %long
z = slopematrix; %180x360
surf(k, m, z)
%surf(k, m, z)
save CE1_2C_slope_plot.mat
%save CE2_2C_slope_plot.mat

回答(1 个)

surf(k, m, z.')
Remember that the rows correspond to y not to x

5 个评论

I am not sure how that helps me change the fact that the lattitude matrix has 180 and the longitude matrix has 360
A demonstration that transposing z does work:
k = 1:180; %lat make have 180x 360 matrix
m = 1:360; %long
slopematrix = sort(rand(length(k), length(m)));
size(slopematrix)
ans = 1×2
180 360
z = slopematrix;
try
surf(k, m, z)
disp("(k,m,z) succeeded!");
catch ME
disp("(k,m,z) failed!");
end
(k,m,z) failed!
try
surf(k, m, z.')
disp("(k,m,z.') succeeded!");
catch ME
disp("(k,m,z.') failed!");
end
(k,m,z.') succeeded!
I don't understand why you are saying to transpose z when I am trying to transpose k and m to fit z. What exactly does transposing z do and won't I be messing with the placement of the values in the slope matrix?
lat is vertical, not horizontal, so you should not be using it as your x.
k = 1:180; %lat make have 180x 360 matrix
m = 1:360; %long
slopematrix = sort(rand(length(k), length(m)));
size(slopematrix)
ans = 1×2
180 360
z = slopematrix;
surf(m, k, z)
xlabel('long')
ylabel('lat')
zlabel('slope')
Ok. I see that now. Thank you very much for your time and patience.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by