Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Plotting Temperature with respect to time in MATLAB from a file??

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hello!!! Everyone,

I am making a Data Logger Project and had stored Log in Memory Card, and wants to plot the Temperature Data with Respect to time in MATLAB (or any other software, which ever is simple)

18:41:03,05/10/13,025.7C,+024.5C,060.0%,000.00m/s,0,0000.0mm,0000.0mm
18:41:17,05/10/13,025.7C,+024.8C,060.0%,000.00m/s,0,0000.0mm,0000.0mm
18:41:32,05/10/13,025.4C,+024.8C,059.3%,000.00m/s,0,0000.0mm,0000.0mm
18:41:48,05/10/13,025.7C,+025.1C,059.3%,000.00m/s,0,0000.0mm,0000.0mm
18:29:50,05/10/13,026.0C,+024.8C,059.0%,000.00m/s,0,0000.0mm,0000.0mm
18:30:04,05/10/13,025.7C,+024.8C,058.7%,000.00m/s,0,0000.0mm,0000.0mm

18:30:04-> Time
05/10/13-> Date
025.7C -> Unit Temperature
+024.8C -> Atmosphere Temperature
058.7% -> Relative Humidity

Rest are Not useful

Can any one tell how to plot Temperature w.r.t time for each day on Separate graphs(Figure in MATLAB)

Please Someone help its urgent

View attachment LOGGER.zip
 
Last edited:

No i dont know python, and did it by using MATLAB and datetick functions and example provide in the MATLAB Documentation.
 

In my view you should have a parser code to classify your data .......I mean where you can get array of time variable and temperature variable..... The you can convert date and time variables in UTC time and then you can have that as x axles and temperature as y axis for plot command in matlab ....refer conversion of date time to UTC time......
Refer this-

https://www.mathworks.in/matlabcent...utc-time-to-datenum-supports-vectors-winlinux

https://stackoverflow.com/questions/12661862/converting-epoch-to-date-in-matlab

Good luck
 
Last edited:

This is a bit clunky, but it should be fine for this relatively small amount of data:
Code:
close all; clear all; clc; fclose all;

% Open the file in raw byte format
fid = fopen('logger.csv');
A = fread(fid);
fclose(fid);

% Replace endlines with commas
A(A==char(10)) = ',';

% Reinterpret as a string
str = sscanf(char(A),'%s');

% Split string at commas
B = strsplit(str,',');

% Reshape into 9 columns, discarding remainder
remainder = rem(length(B),9);
C = reshape(B(1:end-remainder),9,[]).';

% Number of data points
N = size(C,1);

% Parse Times
Times = zeros(N,3);
for i = 1:N
   tmp = char(strsplit(char(C(i,1)),':'));
    for j = 1:3
       Times(i,j) = sscanf(tmp(j,:),'%d'); 
    end
end
TIMES_IN_SECS = 60*60*Times(:,1) + 60*Times(:,2) + Times(:,3);

% Parse date
Dates = char(C(:,2));
Dates = str2num(Dates(:,[1,2,4,5,7,8])); %#ok
UniqueDates = unique(Dates);
UniqueDateStrings = unique(C(:,2));

% Parse temperature
Temp = zeros(N,1);
for i = 1:N
   tmp = char(C(i,3));
   Temp(i) = sscanf(tmp(tmp~='C'),'%f'); 
end

% Plot
for i = 1:size(UniqueDates,1)
    idx = Dates == UniqueDates(i,:);
    figure();
    plot(TIMES_IN_SECS(idx), Temp(idx));
    grid on;
    title(['Date: ', char(UniqueDateStrings(i))]);
    xlabel('Time (secs)');
    ylabel(['Temperature (', char(176),'C)']);
end
If you don't have the latest version of Matlab, you can use the free GNU Octave version of strsplit (see attachment).
 

Attachments

  • strsplit.zip
    1.2 KB · Views: 70

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top