×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

(OP)
Hi,

I have a large set of senor data collected every minute for 102 days.
In which, 1st columen contains dates in the format of YYYY,MM,DD,HH:MM. And 2nd column contains values, whole number from (8 - 20)

My problem is that the sensor wasn't 100% reliable hence there were some gaps scattered through column 1 and 2. These gaps were deleted when downloading the data from the sensor, Hence it looks something like this

09/11/2013 18:38
09/11/2013 18:39
09/11/2013 18:40
09/11/2013 18:41
09/11/2013 18:42
09/11/2013 18:43
11/11/2013 7:29
11/11/2013 7:30
11/11/2013 7:31
11/11/2013 7:32
11/11/2013 7:33
11/11/2013 7:34


In column 2, I have some data which despite have a date in the first column the value is shown as zero, which is basically a value when the sensor just started up. I have replaced these zero as NaN.

I intention is to plot a graph that will ignore the missing dates and just joint the last and first values of the data together, e.g. from above, data point 09/11/2013 18:43 will join to 11/11/2013 7:29, and the x-axis will not show all the minutes between the missing gap.

If some can give me a hand that would be much appreciated.

Many Thank

John

RE: Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

You need to plot a true xy graph (in Excel terms) rather than a line chart. So you need to generate a true time variable from your date and time

That being said it sounds like a common requirement so i'd guess it has been solved already

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

RE: Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

(OP)
I tried to use plot and scatter, but I still get the a big gap, for my particular case, the bigest gap I have is about 16 days, my senors take samples every minute. I am relatively new to matlab, and I have a feeling I am missing something fundamental here.

RE: Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

(OP)
My data looks something like this below:

Dates Data 1 Data 2
09/11/2013 18:38 20 19
09/11/2013 18:39 19 NaN
09/11/2013 18:40 NaN 11
09/11/2013 18:41 4 8
09/11/2013 18:42 18 2
09/11/2013 18:43 4 11
11/11/2013 7:29 NaN 15
11/11/2013 7:30 2 10
11/11/2013 7:31 11 14
11/11/2013 7:32 14 NaN
11/11/2013 7:33 NaN 20
11/11/2013 7:34 NaN 18



And my m code is something like below, can anyone tell me what the gap is still be ploted out?

Many Thanks

function plotParticleSensorsALL(X1, YMatrix1, YMatrix2, YMatrix3, Start_date, Finish_date)

% X1: vector of x data
% YMATRIX1: 2 sets
% YMATRIX2: 2 sets
% YMATRIX3: 2 sets
% Start_date: first date of the data record
% Finish_date: Last date of the data record



% Create figure
figure1 = figure('Position', [209, 249, 1400, 750]);
%----------------------------------------------------------------------------------------------------
% Creating 4um graph
% Create axes
axes1 = axes('Parent',figure1,...
'XLim',[Start_date Finish_date],...
'Position',[0.16 0.710521421117724 0.805714285714286 0.211850457988714]);

%% Uncomment the following line to preserve the X-limits of the axes

box(axes1,'on');
hold(axes1,'all');
datetick('x','dd/mm/yyyy HH:MM','keepticks')

% Create multiple lines using matrix input to plot
plot1 = plot(X1,YMatrix1,'Parent',axes1,'MarkerFaceColor',[0 0 0],...
'LineWidth',2);
set(plot1(1),'DisplayName','A (Main)');
set(plot1(2),'DisplayName','B (Pilot)');


% Create xlabel
xlabel('Time','FontSize',12);

% Create ylabel
ylabel('m','FontSize',12);

% Create title
title('1st graph','FontSize',14);

%--------------------------------------------------------------------------------------------------------
% Creating 2nd graph
% Create axes
axes2 = axes('Parent',figure1,...
'XLim',[Start_date Finish_date],...
'Position',[0.16 0.397007907604211 0.805714285714285 0.211850457988714]);



%% Uncomment the following line to preserve the X-limits of the axes

box(axes2,'on');
hold(axes2,'all');
datetick('x','dd/mm/yyyy HH:MM','keepticks')

% Create multiple lines using matrix input to plot
plot2 = plot(X1,YMatrix2,'Parent',axes2,'MarkerFaceColor',[0 0 0],...
'LineWidth',2);
set(plot2(1),'DisplayName','A (Main)');
set(plot2(2),'DisplayName','B (Pilot)');

% Create xlabel
xlabel('Time','FontSize',12);

% Create ylabel
ylabel('m','FontSize',12);

% Create title
title('2nd graph','FontSize',14);
%----------------------------------------------------------------------------------------------------
% Creating 3rd graph
% Create axes
axes3 = axes('Parent',figure1,...
'XLim',[Start_date Finish_date],...
'Position',[0.16 0.0537646643609681 0.805714285714285 0.211850457988714]);


%% Uncomment the following line to preserve the X-limits of the axes

box(axes3,'on');
hold(axes3,'all');
datetick('x','dd/mm/yyyy HH:MM','keepticks')

% Create multiple lines using matrix input to plot
plot3 = plot(X1,YMatrix3,'Parent',axes3,'MarkerFaceColor',[0 0 0],...
'LineWidth',2);
set(plot3(1),'DisplayName','A (Main)');
set(plot3(2),'DisplayName','B (Pilot)');

% Create xlabel
xlabel('Time','FontSize',12);

% Create ylabel
ylabel('PPM','FontSize',12);

% Create title
title('3rd graph','FontSize',14);

%----------------------------------------------------------------------------------------------------

% Create legend
legend1 = legend(axes1,'show');
set(legend1,...
'Position',[0.0068918583500594 0.432503118133938 0.110947042348466 0.159788166544924]);

RE: Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

or replace them by =na()
... that gets ignored by the plot.

=====================================
(2B)+(2B)' ?

RE: Plotting line graph - ignoring missing dates (YYYY, MM, DD, HH:MM)

.. or delete that row of course.

=====================================
(2B)+(2B)' ?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources