Help with the surf function

조회 수: 8 (최근 30일)
Falon Treis
Falon Treis 2021년 4월 28일
댓글: Falon Treis 2021년 4월 28일
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개)

Walter Roberson
Walter Roberson 2021년 4월 28일
surf(k, m, z.')
Remember that the rows correspond to y not to x
  댓글 수: 5
Walter Roberson
Walter Roberson 2021년 4월 28일
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')
Falon Treis
Falon Treis 2021년 4월 28일
Ok. I see that now. Thank you very much for your time and patience.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by