%% Data Extraction and Visualization Tool
%% Extract data that has been stored via putty in the log file_in_loadpath
%% Version: 00
%% Author: MA

clear all
close all
clc

filename = "putty.log"; %% file must be in same folder

%% Extract data and store to variable data
dataIn_raw = fileread(filename);
dataIn_raw = strsplit(dataIn_raw, "\n");

for i = 1:length(dataIn_raw)
  
  data_hlpVar = strtrim (strsplit (dataIn_raw{i}, {":", ","}));
  
  for j = 1:length(data_hlpVar) 
    
    data(i,j) = str2double(data_hlpVar{1,j});
      
  endfor
    
endfor
  
%% Reshape data 
start = 9; 
data = data(start:end-1,1:end); # define start value, remove last 1 entries, most of the time there is corrupted data inside

%% Define x and y values of plot
x_data = data(:,2)/1000; # conversion from ms to s
y1_data = data(:,4); # hot junction data
y2_data = data(:,6); # cold junction data

%% Plot data
figure(1)
plot(x_data, y1_data);
hold on
plot(x_data, y2_data);
grid on
xlabel('Time [sec]');
ylabel('Temperature [°C]');

legend('Hot Junction','Cold Junction',"location","northeast");
title('Hot & Cold Junction Temperature vs. Time');

  
  
  
  