how to plot multiple curves in the same figure

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

 Akzeptierte Antwort

KSSV
KSSV am 31 Okt. 2017
Bearbeitet: KSSV am 31 Okt. 2017

0 Stimmen

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')

Weitere Antworten (2)

M
M am 31 Okt. 2017

0 Stimmen

Have a look at the hold on function
geofo
geofo am 3 Dez. 2021
Bearbeitet: geofo am 3 Dez. 2021

0 Stimmen

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

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Gefragt:

am 31 Okt. 2017

Bearbeitet:

am 3 Dez. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by