logspace 函数参考文档 : https://ww2.mathworks.cn/help/matlab/ref/logspace.html
logspace 语法 :
logspace(-1,1, 100) : 生成
到
之间的 100 个值 ;
% 生成 10 的 -1 次方到 10 的 1 次方之间 100 个数值
y = logspace(-1,1, 100);
semilogx 函数参考文档 : https://ww2.mathworks.cn/help/matlab/ref/semilogx.html
semilogx 函数绘制半对数图 : 绘制的坐标轴 , x 轴是对数刻度, y 轴是线性刻度 ;
% x 轴是对数刻度, y 轴是线性刻度
semilogx(x, y);
semilogy 函数参考文档 : https://ww2.mathworks.cn/help/matlab/ref/loglog.html
semilogy 函数绘制半对数刻度图 : 绘制的坐标轴 , x 轴是对数刻度, y 轴是对数刻度 ;
% x 轴是线性刻度, y 轴是对数刻度
semilogy(x, y);
loglog 函数参考文档 : https://ww2.mathworks.cn/help/matlab/ref/semilogy.html
loglog 函数绘制双对数刻度图 : 绘制的坐标轴 , x 轴是线性刻度, y 轴是对数刻度 ;
% x 轴是对数刻度, y 轴是对数刻度
loglog (x, y);
代码示例 :
% 生成 10 的 -1 次方到 10 的 1 次方之间 100 个数值
x = logspace(-1, 1, 100);
% 生成 y 是 x 的平方
% 加假如 x 是 10 的 -1 次方 , 其平方是 10 的 -2 次方
y = x .^ 2;
% 绘制第一个曲线
subplot(2,2,1);
% 使用线性的方式绘图
plot(x, y);
% 添加标题
title('Plot ( x 线性 y 线性 )');
% 绘制第二个曲线
subplot(2,2,2);
% x 轴是对数刻度, y 轴是线性刻度
semilogx(x, y);
% 添加标题
title('Semilogx ( x 对数 y 线性 )');
% 绘制第三个曲线
subplot(2,2,3);
% x 轴是线性刻度, y 轴是对数刻度
semilogy(x, y);
% 添加标题
title('Semilogy ( x 线性 y 对数 )');
% 绘制第四个曲线
subplot(2,2,4);
% x 轴是对数刻度, y 轴是对数刻度
loglog(x, y);
% 添加标题
title('Loglog ( x 对数 y 对数 )');
绘图效果 :
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有