%       Trasmissione.m
%   
%
clear all
close all
clc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   DEFINIZIONE DELLE UNITA' DI MISURA DEL SISTEMA INTERNAZIONALE (SI)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
m = 1; dm = 0.1*m; cm = 0.01*m; mm = 0.001*m; km = 1000*m;
kg = 1;
N = 1;
kN = 1000*N;
secondo = 1; ora = 60*60*secondo;  minuti = 60*secondo;
ms = 0.001*secondo;
Pa = 1;
rad = 1;
gradi =( pi/180)*rad;
bar = 10^5*Pa;
lt = 0.001*m^3;
rpm = 2*pi/60*rad/secondo;
g = 9.8*m/secondo^2;


Tau_in=10*N*m;     % Coppia in ingresso

J1=0.1;
b1=0.1;
K1=0.1;
R=15*cm;
b2=0.1;
K2=0.1;

    figure(1)
    clf

for M2=0.1:0.2:1
    
    p1_0=0;
    th1_0=0;
    p2_0=0;
    x2_0=0;


    Tfin=0.3*secondo;
    Ts=Tfin/2000;

    sim('trasmissione_mdl',Tfin);  % Simulazione trasmissione

    Lw=1;


    subplot(211)
    plot(t,w1,'b','LineWidth',Lw)
    hold on
    title('Velocità angolare')
    ylabel('w1 [rad/s]')
    xlabel('Time [s]')
    zoom on
    grid on

    subplot(212)
    plot(t,xdot2,'b','LineWidth',Lw)
    hold on
    title('Velocità lineare')
    ylabel('xdot2 [m/s]')
    xlabel('Time [s]')
    zoom on
    grid on

end