matlab画图图例
时间: 2023-08-26 15:15:00 浏览: 159
在Matlab中,可以使用legend函数来为图像添加图例。legend函数的格式为legend('string1','string2',...),其中'string1'、'string2'等是用于标注各个数据组的实际意义的字符串。例如,如果我们在一张图中绘制了三条曲线,可以使用以下代码为它们添加图例:
```
x = 0:0.02*pi:2*pi;
y1 = sin(x);
y2 = cos(x);
y3 = sin(3*x).*cos(x);
plot(x,[y1;y2;y3])
legend('sin(x)','cos(x)','sin(3x)cos(x)')
```
这样,图例中会显示出三个标签分别对应着这三条曲线。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [如何使用Matlab绘制图形并标记图例](https://blog.csdn.net/xuehuitanwan123/article/details/97614970)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [MATLAB的二维线图绘图函数plot()实例积累](https://blog.csdn.net/wenhao_ir/article/details/124319299)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文