Commit fcbc4e93 authored by Sebastian Hofmann's avatar Sebastian Hofmann ☝🏽
Browse files

add distribution of track length mean median

parent 09014d72
% ** coded by Sebastian Hofmann **
% ** s.m.hofmann@mailbox.org ** sebastian.hofmann@tuhh.de **
%
% Load .mat from "loadDat_experimental_server_particles.m"
% Output is a distribution of track length
%
% INFORMATION
% 1. ---
close all
clear all
%% Load .mat file with separated tracks
[FileName,FilePath] = uigetfile('*.mat','Select the .mat file', ...
'./','MultiSelect', 'off');
load(strcat(FilePath,FileName));
%% Track length statistics
trackmax = max(trackID)+1; % latest trackID
[a b c] = unique(trackID);
track_length = accumarray(c,1); % evaluate respective track length
track_length = accumarray(trackID+1,1); % evaluate respective track length
track_length_max = max(track_length); % longest single track
track_length_avg = mean(track_length); % average track length
track_length_med = median(track_length); % 50% percent median of all track lengths
track_length_iqr = iqr(track_length); % calculate interquartile range
track_length_sorted = sort(track_length); % sort in ascending order
iqr_25 = track_length_sorted(round(size(track_length_sorted,1).*0.25)); % look for 25th quartile value in respective row
iqr_75 = track_length_sorted(round(size(track_length_sorted,1).*0.75)); % look for 75th quartile value in respective row
bin_spaces = linspace(0,3000,151); % subdivided in 300 bins, means 10 track lengths are in 1 bin
[PDF_track_length, edges_track]=histcounts(track_length,bin_spaces);
%% Save SINGLE results of current run
fname = sprintf('graph_DistrTrackLength_exp_1024_740_450rpm'); % Enter filename here!
fpath = sprintf('C:/Users/sm1sh/Matlab/PTV_ResultsSH/Results_Paper'); % Enter filepath here!
save(strcat(fpath,'./',fname,'.mat'),...
'track_length_avg','track_length_med','track_length_iqr',...
'track_length_sorted','iqr_25','iqr_75','PDF_track_length','edges_track')
%% Load results seperately and give them numbers
clear all
close all
[FileName,FilePath] = uigetfile('*.mat','Select the .mat file', ...
'./','MultiSelect', 'off');
load(strcat(FilePath,FileName));
PDF_track_length1 = PDF_track_length; %exp, 252rpm, 180µm, 1000
edges_track1 = edges_track;
track_length_med1 = track_length_med;
track_length_avg1 = track_length_avg;
iqr_251 = iqr_25;
iqr_751= iqr_75;
PDF_track_length2 = PDF_track_length; %exp, 252rpm, 740µm, 1024
edges_track2 = edges_track;
track_length_med2 = track_length_med;
track_length_avg2 = track_length_avg;
iqr_252 = iqr_25;
iqr_752 = iqr_75;
PDF_track_length3 = PDF_track_length; %exp, 450rpm, 180µm, 1000
edges_track3 = edges_track;
track_length_med3 = track_length_med;
track_length_avg3 = track_length_avg;
iqr_253 = iqr_25;
iqr_753 = iqr_75;
PDF_track_length4 = PDF_track_length; %exp, 450rpm, 740µm, 1024
edges_track4 = edges_track;
track_length_med4 = track_length_med;
track_length_avg4 = track_length_avg;
iqr_254 = iqr_25;
iqr_754 = iqr_75;
%% Save all results in ONE .mat
fname = sprintf('graph_DistrTrackLength_exp_all_180740252_180740450_ycut30'); % Enter filename here!
fpath = sprintf('C:/Users/sm1sh/Matlab/PTV_ResultsSH/Results_Paper'); % Enter filepath here!
save(strcat(fpath,'./',fname,'.mat'),...
'PDF_track_length1','PDF_track_length2','PDF_track_length3','PDF_track_length4',...
'edges_track1','edges_track2','edges_track3','edges_track4',...
'track_length_med1','track_length_med2','track_length_med3','track_length_med4',...
'track_length_avg1','track_length_avg2','track_length_avg3','track_length_avg4',...
'iqr_251','iqr_252','iqr_253','iqr_254',...
'iqr_751','iqr_752','iqr_753','iqr_754')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Create plots
fig = figure(1)
g1 = semilogy(edges_track1(2:end),PDF_track_length1,...
"d",'MarkerEdgeColor','blue','LineWidth',1.2,'MarkerSize',7) % 180, 252 rpm
hold on
g2 = semilogy(edges_track2(2:end),PDF_track_length2,...
"d",'MarkerEdgeColor',[0.75 0.75 0],'LineWidth',1.2,'MarkerSize',7) % 740, 252 rpm
g3 = semilogy(edges_track3(2:end),PDF_track_length3,...
"x",'MarkerEdgeColor','blue','LineWidth',1.3,'MarkerSize',9) % 180, 450 rpm
g4 = semilogy(edges_track4(2:end),PDF_track_length4,...
"x",'MarkerEdgeColor',[0.75 0.75 0],'LineWidth',1.3,'MarkerSize',9) % 740, 450 rpm
%med1 = xline(track_length_avg1,'-.',{'Median 1'},'FontSize',12,'LineWidth',1.2,'interpreter','latex')
%med2 = xline(track_length_avg2,'-.',{'Median 2'},'FontSize',12,'LineWidth',1.2,'interpreter','latex')
%med3 = xline(track_length_avg3,'-.',{'Median 3'},'FontSize',12,'LineWidth',1.2,'interpreter','latex')
%med4 = xline(track_length_avg4,'-.',{'Median 4'},'FontSize',12,'LineWidth',1.2,'interpreter','latex')
LineHandle.NodeChildren.LineWidth = 10
hold off
grid on
%title("Track length statistics")
axes = gca;
axes.FontSize = 16;
xlabel("Track length / -",'FontSize',19,'interpreter','latex');
ylabel("Number of tracks / -",'FontSize',21,'interpreter','latex');
[~, objh] = legend([g1 g2 g3 g4],{
'180 µm, 1000 kg m^{-3}, 252 rpm',...
'732 µm, 1024 kg m^{-3}, 252 rpm',...
'180 µm, 1000 kg m^{-3}, 450 rpm',...
'732 µm, 1024 kg m^{-3}, 450 rpm'},...
'FontSize',14,'Location','Northeast')
%objhl = findobj(objh, 'type', 'line'); %// objects of legend of type line
%set(objhl, 'Markersize', 8,'LineWidth',1.6); %// set marker size as desired
set(0,'DefaultAxesFontSize', 18)
set(gcf,'PaperPositionMode','auto')
set(fig,'units','centimeters','position',[10,5,25,12])
%print(strcat('C:/Users/sm1sh/GIT/paper-4dptv-simu/content/figs','./','track_length'),'-dpng','-r600');
%SH%%#%%%%%%%%%%%%%%%%#%%%%%%%####
%%%%%%%%%%%%#%v~~~~~~\%%%#%%%%%%%%
%%%%%%%#%%%%v' ~~~~\%%%%%%%
%%%%#%%%%%%v'dHHb a%%%#%%%%%%
%%%%%%%#%%v'dHHHA :%%%%%%#%%%%
%%%%%#%%%v' VHHHHaadHHb:%#%%%%%%%%
%%%%%%%#v' `VHHHHHHHHb:%%%%%#%%%
%%%#%%%v' `VHHHHHHH:%%%#%%%%%
%%%%%%%' dHHHHHHH:%%#%%%%%%
%%%%#%% dHHHHHHHH:%%%%%%%%%
%%%%%%% dHHHHHHHHH:%%#%%%%%%
%%#%%%% VHHHHHHHHH:%%%%%#%%%
%%%%%%# b HHHHHHHHV:%%%#%%#%%
%%%%%%% Hb HHHHHHHV'%%%%%%%%%%
%%%%#%% HH dHHHHHHV'%%%#%%%%%%%
%%%#%%% VHbdHHHHHHV'#%%%%%%%%%%%
%%%%%#% VHHHHHHHV'%%%%%#%%#%%%%
%%%#%%%% VHHHHHHH:%%#%%#%%#%%#%
%%#%%#%%#%%#%%#%%#%%#%%#%%#%%#%%#%
%%#%%#%%#%%#%%#%%#%%#%%#%%#%%#%IMS
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment