how to plot multiple curves in the same figure

156 次查看(过去 30 天)
Hello everyone I'm new in matlab and I want to know how can I plot multiple curves in the same figure knowing that every single curve has it's own expression(function).Do I have to write the code for every single function in has own file?? any idea please and thanks

采纳的回答

KSSV
KSSV 2017-10-31
编辑:KSSV 2017-10-31
Use hold on
figure
hold on
plot(rand(10,1),'r')
plot(rand(10,1),'b')
plot(rand(10,1),'g')
legend('data1','data2','data3')

更多回答(2 个)

M
M 2017-10-31
Have a look at the hold on function

geofo
geofo 2021-12-3
编辑:geofo 2021-12-3
plot([rand(10,1), rand(10,1), rand(10,1)])
legend('data1','data2','data3')
Use colororder before calling plot to have your prefered colors.
The vectors v1, v2, v3, in plot([v1, v2, v3]) must be column vectors, all with the same dimension

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by