% Code to plot simulation results for sscfluids_clutch_slave_cyl
%% Plot Description:
%
% This script generate the plot between the applied force to the
% single-stage master cylinder and the pressure developed
% inside the slave cylinder.
%

% Copyright 2020 The MathWorks, Inc.

%% Parameterize the model

sscfluids_clutch_slave_cyl_input;

%% Generate new simulation results if they don't exist or if they need to be updated
if ~exist('simlog_sscfluids_clutch_slave_cyl', 'var') || ...
        pm_simlogNeedsUpdate(simlog_sscfluids_clutch_slave_cyl)
    sim('sscfluids_clutch_slave_cyl.slx',simT)      % Simulating model
end
%% Create figure for the results
if ~exist('h_sscfluids_clutch_slave_cyl', 'var') || ...
        ~isgraphics(h_sscfluids_clutch_slave_cyl, 'figure')
    h_sscfluids_clutch_slave_cyl = figure('Name', 'h_sscfluids_clutch_slave_cyl');
end

clf(h_sscfluids_clutch_slave_cyl);

%% Load the model and simulate to generate pressure curve

% Plotting output from Simscape(TM) slave cylinder model.


i1 = plot(logsout_sscfluids_clutch_slave_cyl{2}.Values.Data,...
    logsout_sscfluids_clutch_slave_cyl{1}.Values.Data);
i2 = xlabel('Force applied by driver on push rod (N)');
i3 = ylabel('Pressure (Pa)');
i4 = title('Slave cylinder pressure (Pa)');
i1.LineWidth = 2;
i2.FontSize = 14;
i3.FontSize = 14;
i4.FontSize = 14;
grid on


% Clearing temporary variables

clear i1 i2 i3 i4