SKMS
SKMS

Reputation: 11

Draw smooth line through data points in MATLAB figure

I have few MATLAB fig files. All these fig files have same prefix name (Pol_test_) and different suffix name(10,20,30....200). For example, Pol_test_10, Plo_test_20 so on. Every fig file has five sets of data points. Is there a simple way to connect/join these data points using a line? I want both lines with markers in the result. I don't want to plot them again as it will take a lot of time. Any suggestions to loop through all the figures?

Upvotes: 1

Views: 314

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112669

Say you have a figure such as this, containing several plots with only markers:

plot(1:5, [3 6 4 3 5], 'o');
hold on
plot(2:7, [9 6 2 6 9 4], '*');

enter image description here

To have lines connecting the markers, you only need to set the 'LineStyle'property of each Line object that was produced by plot. For example, '-' will give a solid line, and '--' will give a dashed line:

ch = get(gca, 'Children');
[ch.LineStyle] = deal('-');

enter image description here

Upvotes: 1

Related Questions