Azzera filtri
Azzera filtri

can anyone tell me how to plot a three curves with different x and y values for all curve in single plot?

2 visualizzazioni (ultimi 30 giorni)
Multiplot curve

Risposta accettata

KSSV
KSSV il 20 Set 2018
Read about hold on
figure
hold on
plot(..)
plot(...)

Più risposte (2)

ANKUR KUMAR
ANKUR KUMAR il 20 Set 2018
Modificato: ANKUR KUMAR il 20 Set 2018
As you have not given any specific data set. I am taking a random data to give you an example.
Example 1
Just plot all three lines subsequently.
col={'r','b','k'}
for kk=1:3
aa=spline((0:15),randi(10,1,16),(0:0.1:15))
x=randi(100,1,1);
plot((x:0.1:x+15),aa,col{kk})
hold on
end
legend({'Line 1','Line 2','Line 3'})
Don't worry if you don't understand the third and fourth line. It's just the random data.
Example 2
If you want to skip using the loop, you can plot using cellfun too. The following loop is just to create the random data set. If you have the dataset, just put them in a cell.
col={'r','b','k'}
for kk=1:3
YY{kk}=spline((0:15),randi(10,1,16),(0:0.1:15))
x=randi(10,1,1);
XX{kk}=(x:0.1:x+15);
end
hold on
cellfun(@(x,y,z) plot(x,y,z),XX,YY,col,'uni',0)
legend({'Line 1','Line 2','Line 3'})
  4 Commenti

Accedi per commentare.


KALYAN ACHARJYA
KALYAN ACHARJYA il 20 Set 2018
Check here, It may be helpful.
Also check here

Community Treasure Hunt

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

Start Hunting!

Translated by