matlab2020b 双坐标轴
时间: 2024-01-12 14:22:13 浏览: 88
matlab坐标轴设置.pdf
以下是使用MATLAB 2020b创建双坐标轴的示例代码:
1. 修改曲线和坐标轴颜色:
```matlab
x = 0:0.1:10;
y1 = sin(x);
y2 = cos(x);
figure;
[hAx, hLine1, hLine2] = plotyy(x, y1, x, y2);
set(hLine1, 'Color', 'r');
set(hLine2, 'Color', 'b');
xlabel('X轴');
ylabel(hAx(1), 'Y1轴');
ylabel(hAx(2), 'Y2轴');
set(hAx(1), 'YColor', 'r');
set(hAx(2), 'YColor', 'b');
```
2. 使用两个y轴在一个图表上绘制三个数据集:
```matlab
x = linspace(0, 10);
y1 = 200 * exp(-0.05 * x) .* sin(x);
y2 = 0.8 * exp(-0.5 * x) .* sin(10 * x);
y3 = 0.2 * exp(-0.5 * x) .* sin(10 * x);
figure;
[hAx, hLine1, hLine2] = plotyy(x, y1, [x', x'], [y2', y3']);
```
阅读全文