Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Multiplot curve

Réponse acceptée

KSSV
KSSV le 20 Sep 2018
Read about hold on
figure
hold on
plot(..)
plot(...)

Plus de réponses (2)

ANKUR KUMAR
ANKUR KUMAR le 20 Sep 2018
Modifié(e) : ANKUR KUMAR le 20 Sep 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 commentaires
Sathyamoorthy R
Sathyamoorthy R le 20 Sep 2018
I am getting the following error
Error using linspace Too many input arguments
ANKUR KUMAR
ANKUR KUMAR le 20 Sep 2018
Cross check you prog. I have run twice the above prog.

Connectez-vous pour commenter.


KALYAN ACHARJYA
KALYAN ACHARJYA le 20 Sep 2018
Check here, It may be helpful.
Also check here

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by