How do I can do a discontinuous curve in matlab?
5 views (last 30 days)
Show older comments
I'm trying to plot a time serie with depth in the 'y' axis and concentration of certain elements in de 'x' axis. However in my data I have depths where there are no values of concentration (but that doesn't mean a zero concentration). I want a curve that shows the portions where there are values of concentration, but also the portions where there are not.
I have my data in a .dat file. At the moment of running the script an error tells me that the number of file must be the same :(
How can I say to matlab that I dont want curve in the portions where there are no values, and I want it where there are, and that I want to see it in a same ploT?
(Sorry for my english :( )
0 Comments
Accepted Answer
Walter Roberson
on 7 Oct 2015
Replace the missing values with NaN and nothing will be plotted there.
0 Comments
More Answers (2)
Image Analyst
on 7 Oct 2015
Make one of the x be a NaN - that way it won't plot and there will not be any connecting lines. For example
% First section
x1 = linspace(0, 2*pi, 100);
y = cos(x1);
% Second Section.
x2 = linspace(2*pi, 4*pi, 100);
% Make first element of x2 be a nan
x2(1)=nan;
y = [y, sin(x2)];
plot([x1, x2], y, 'b-', 'LineWidth', 3);
grid on;
0 Comments
See Also
Categories
Find more on Annotations 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!