can anyone tell me how to plot a three curves with different x and y values for all curve in single plot?
2 views (last 30 days)
Show older comments
Multiplot curve
0 Comments
Accepted Answer
More Answers (2)
ANKUR KUMAR
on 20 Sep 2018
Edited: ANKUR KUMAR
on 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 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!