matlabplot图例
时间: 2023-10-19 19:33:19 浏览: 105
在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)')
这段代码将在图形中绘制三条曲线,并在图例中显示相应的文本。图例函数legend('sin(x)','cos(x)','sin(3x)cos(x)')将在图形的右上角添加一个图例,分别标注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* [MATLAB Plot Gallery - Line Plot 2D(二):用图例创建线图-matlab开发](https://download.csdn.net/download/weixin_38685793/19195105)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [如何使用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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文