Use matlab's surf to draw a three-dimensional surface map

Task requirements:

  • In a recent experiment, I encountered a parameter discussion problem. There are two independent variables and one dependent variable. The two independent variables may affect each other. It is necessary to discuss the parameters through experiments to find the value of the two independent variables when the dependent variable is the maximum. .
  • When drawing an image, it is natural to think that a three-dimensional image can be drawn, where the x-axis and y-axis represent two independent variables, and the z-axis represents the dependent variable

MATLAB code:

% 用matlab的surf画的三维曲面图

clc,clear,close all
x=[1, 2, 3, 4, 5, 6];
y=[19,23,27,31,35];
[X,Y]=meshgrid(x,y);
Z=[93,93.4,95,96,97,98;
    93,93.4,95,96,97,98;
    93,93.4,95,96,97,98;
    93,93.4,95,96,97,98;
    93,93.4,95,96,97,98];
% mesh(X,Y,Z)

surf(X,Y,Z);
%%设置三维曲面x轴,y轴,z轴,标题对应内容及三个坐标轴的取值范围%%
set(gca,'xtick',[1 2 3 4 5 6])
set(gca,'xticklabel',{
    
    '0.01','0.003', '0.001','0.0003','0.0001','0.00003'})

% xticks([0.01  0.003  0.001  0.0003  0.0001 0.00003])
% xticklabels({
    
    '0.01','0.003','0.001','0.0003','0.0001','0.00003'})
set(gca,'ytick',[19  23  27 31  35])
set(gca,'yticklabel',{
    
    '19','23', '27','31','35'})
zlim([90 100])

xlabel('Learning rate');
ylabel('Patch size');
zlabel('OA(%)');


% t=-2:0.5:2;
% [x,y] =meshgrid(t);%%表示区域网格控制,目地是为了让x,y形成格点矩阵%%
% z=5*x.^2+8*y^3;
% surf(x,y,z);
% %%设置三维曲面x轴,y轴,z轴,标题对应内容及三个坐标轴的取值范围%%
% xlabel('Learning rate');
% ylabel('Patch size');
% zlabel('OA(%)');
% % title('surf三维曲面图');
% axis([-2.5 2.5 -2.5 2.5 -5 25]);

Rendering effect:

insert image description here

Guess you like

Origin blog.csdn.net/qq_44828121/article/details/128321494