MatLab画三维图和等高图

a=xlsread('C:\Users\cw\Desktop\每个位置每小时有多少记录.csv');

% a(37:47,1)=4;a(48:59,1)=5;a(60:64,1)=6;a(65:77,1)=7;a(78:92,1)=8;
% a(93:99,1)=9;a(100:104,1)=10;a(105:114,1)=11;a(115:125,1)=12;a(23:36,1)=13;
% A=[a(1:22,1);a(37:104,1);a(105:114,1);a(115:125,1);a(23:36,1)]; %从B矩阵取出第一列的所有行
% B=[a(1:22,2);a(37:104,2);a(105:114,2);a(115:125,2);a(23:36,2)];
% C=[a(1:22,3);a(37:104,3);a(105:114,3);a(115:125,3);a(23:36,3)];

A=a(:,1);
B=a(:,2);
C=a(:,3);
xx=linspace(min(A),max(A),50); %产生min(A)到max(A)均摊的50个点,目的上拟合离散点数量上的不足
yy=linspace(min(B),max(B),50); 
[xt,yt]=meshgrid(xx,yy); %做成二维网格
zt=griddata(A,B,C,xt,yt,'v4'); %用v4点的方式进行填充

surf(xt,yt,zt) %输出三维图
set(gca,'xtick',0:1:10)
set(gca,'xticklabel',{'a','a','a','a','a','a','a','a','a','a','a','a','a'})%x轴改汉字

figure(3),contourf(xt,yt,zt) %输出等高线图
caxis([0,10]);%等高线颜色区间,即z轴数值
%set(gca,'xticklabel',{''})%x轴刻度不显示
set(gca,'xtick',-2:1:13)
colorbar%对等高线添加一个颜色代表的深度
    原文作者:Sun_Hongbin
    原文地址: https://blog.csdn.net/Sun_Hongbin/article/details/89367513
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞