function ModelResults = LoadModelResults(filenm);

load(filenm);

ModelResults.meanElecPow = nanmean(dl.Current.*dl.Voltage);
ModelResults.maxElecPow = max(dl.Current.*dl.Voltage);
ModelResults.Hs = MeasWaveData.SigWaveHeight;
ModelResults.Tp = MeasWaveData.PeakPeriod;
ModelResults.BudalLimit = MeasWaveData.BudalLimit;

ModelResults.PTO_Eff = nanmean((dl.Current.*dl.Voltage)./(dl.Force.*dl.ElonRate));

t = get(Buoy,'t');
%Get Buoy motion results
x = get(Buoy,'x');
xdot = get(Buoy,'xdot');
xddot = get(Buoy,'xddot');
 
%Get Plate motion results
y = get(Plate,'x');
ydot = get(Plate,'xdot');
yddot = get(Plate,'xddot');

%plotting results

Bforce = get(Buoy,'Forces');
Fforce = get(Plate,'Forces');

xoB = get(Buoy,'x0');
xoF = get(Plate,'x0');

Elongation = zeros(length(t),1);
ElongationRate = zeros(length(t),1);
SpringTension = zeros(length(t),1);
StictionTension = zeros(length(t),1);

s = zeros(length(t),3);
for i = 1:length(t)
    [Elongation(i),ElongationRate(i),s(i,:)] = TetherElongations(xoB,x(i,:)',xdot(i,:)',p_aB,xoF,y(i,:)',ydot(i,:)',p_aF);
    if(Elongation(i) > 0)  %If ram is fully retracted, tether is slack and no force is exerted.
        SpringTension(i) = ppval(Spring_Force_Coeffs,Elongation(i));
        %StictionTension(i) = ppval(Stiction_Force_Coeffs,ElongationRate(i));
    else
        Elongation(i) = 0;
        ElongationRate(i) = 0;
    end
end

ModelResults.MeanPTOElongation = mean(Elongation);
ModelResults.MaxPTOElongation = max(Elongation);
ModelResults.MinPTOElongation = min(Elongation);
ModelResults.StdPTOElongation = std(Elongation);

ModelResults.MeanPTOElongationRate = mean(ElongationRate);
ModelResults.MaxPTOElongationRate = max(ElongationRate);
ModelResults.MinPTOElongationRate = min(ElongationRate);
ModelResults.StdPTOElongationRate = std(ElongationRate);


n_windows = 16;

[f, Pxx] = tseries2spectrum(t,Elongation,n_windows);
idx = find(f<=1);
ModelResults.f = f(idx);
ModelResults.S_e = Pxx(idx);

[f, Pxx] = tseries2spectrum(t,ElongationRate,n_windows);
ModelResults.S_edot = Pxx(idx);

n_windows = 32;
[f, Pxx] = tseries2spectrum(t,dl.Voltage-mean(dl.Voltage),n_windows);
ModelResults.S_voltage = Pxx(idx);

[f, Pxx] = tseries2spectrum(t,dl.current-mean(dl.cur),n_windows);
ModelResults.S_current = Pxx(idx);

[f, Pxx] = tseries2spectrum(t,SelectedData.RectifiedCurrent.*SelectedData.RectifiedVoltage-mean(SelectedData.RectifiedCurrent.*SelectedData.RectifiedVoltage),n_windows);
ModelResults.S_pow = Pxx(idx);


end

