clc
clear all
close all

% Load your raw data file
data1 = readmatrix('diagonalsample1_100Infill.xlsx');

temperature1           = data1(:, 2);            % Temperature data (in Celsius)
frequency1             = data1(:, 4);            % Frequency data (in Hz)
storage_modulus1       = data1(:, 38);           % Storage modulus data
loss_modulus1          = data1(:, 39);           % Loss modulus data
tan_delta1             = data1(:, 40);
complex_viscosity1     = data1(:, 43);
shear_storage_modulus1 = data1(:, 44);
shear_loss_modulus1    = data1(:, 45);

% Constants

T_ref = 30;                                       % Reference temperature

% Calculate shift factors using WLF equation

T_shift = temperature1 - T_ref;
alpha = -17.44;                                   % WLF parameter
beta = 51.6;                                      % WLF parameter
shift_factor = 10 .^ (alpha * (T_shift ./ (T_shift + beta)));

% Shift frequency values
frequency_shifted = frequency1 .* shift_factor;

% Plot master curve
figure;
loglog(frequency_shifted, storage_modulus1, 'o', 'MarkerSize', 15, 'MarkerFaceColor', 'r');
hold on
loglog(frequency_shifted, loss_modulus1, '^', 'MarkerSize', 15, 'MarkerFaceColor', 'b');
loglog(frequency_shifted, tan_delta1, 's', 'MarkerSize', 15, 'MarkerFaceColor', 'g');

% Graph Labelling
xlabel('Frequency [Hz]','FontSize',48,'FontWeight','bold', 'FontName','Cambria Math')
ylabel('Modulus [Pa]','FontSize',48,'FontWeight','bold', 'FontName','Cambria Math');
xlim([1e-5, 1e10]);
%  ylim([1e7, 1e10]);
axis square
set(gca,'FontSize',48,'LineWidth',3,'FontWeight','bold','FontAngle', 'Normal', 'FontName','Cambria Math')
% legend('Storage Modulus', 'Loss Modulus')
legend('Storage Modulus', 'Loss Modulus', 'Tan(\delta)')
legend('boxoff');
box on
