% Code to plot simulation results for sdl_automotive_clutch
%% Plot Description:
%
% This script generates the plots of the engine and the transmission speed
% during declucthing scenario.
%

% Copyright 2020 The MathWorks, Inc.

%% Parameterize the model

sdl_automotive_clutch_input;

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

clf(h_sdl_automotive_clutch);

%% Load the model and simulate to generate pressure curve

% Plotting output from Simscape(TM) automotive clutch model.


i1 = plot(simlog_sdl_automotive_clutch.Engine.w.series.time,...
    simlog_sdl_automotive_clutch.Engine.w.series.values,...
    simlog_sdl_automotive_clutch.Transmission.w.series.time,...
    simlog_sdl_automotive_clutch.Transmission.w.series.values);
i2 = xlabel('Time (s)');
i3 = ylabel('Rotational speed (rad/s) ');
i4 = legend('Engine','Transmission');
i1(1).LineWidth = 2;
i1(2).LineWidth = 2;
i2.FontSize = 14;
i3.FontSize = 14;
i4.FontSize = 14;
grid on


% Clearing temporary variables

clear i1 i2 i3 i4