MATLAB学习-plot画图
程序员文章站
2022-03-19 15:01:16
...
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
问题
利用MATLAB绘图,设置图形曲线及相关标记
示例
%% 环境:matlab2021a %%
%% 时间:2021-12-8 %%
%% 作者:keegbin %%
%% 功能:(1)测试plot绘图设置 %%
%% (2)plot-Latex解释 %%
clc;
clear;
close all;
[x,y] = meshgrid(-2:0.01:2, -4:0.01:4); % 预设网格
z = (x.*x)/(2*2) + (y.*y)/(4*4); % 计算函数值
figure,mesh(x,y,z); % 显示曲面z及坐标轴
h1 = xlabel("$$ x[m] $$","FontSize",20,"LineWidth",2);
h2 = ylabel("$$ y[m] $$","FontSize",20,"LineWidth",2);
h3 = zlabel("$$ z[m] $$","FontSize",20,"LineWidth",2);
set([h1,h2,h3],"Interpreter","latex","FontSize",20,"LineWidth",2);
h4 = legend("$$ z=\frac{{x^2}}{{2^2}}+\frac{{y^2}}{{4^2}} $$"); % latex分式
set(h4,'Interpreter','latex','Location','SouthOutside',"FontSize",10,"LineWidth",1.5) % 设置legend为latex解释器显示分式
set(gca,"FontName","Times New Roman","FontSize",10,"LineWidth",1);
上一篇: 关闭window时终止程序
下一篇: matplotlib.pyplot画图