rpm=[1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000];
torque_engine_lbf=[50,65,80,92,104,114,120,125,130,133,130,122,110];
torque_engine=torque_engine_lbf.*1.35582;
gear_ratios=[3.54,2.13,1.36,1.03,0.72];
plot(rpm,torque_engine,'c')
colors=['r','g','b','k','m'];
hold on
for i=1:1:5
    torque(i,:)=gear_ratios(i).*torque_engine;
    plot(rpm,torque(i,:),colors(i))
    hold on
end
hold off

%% Teste á velocidade:

speed=linspace(0,120,100000);
colors=['r','g','b','k','m'];
for i=1:1:size(speed,2);
    a(i)=acceleration_drag_response(0.3,2,1.29,speed(i),1000);
end

%% Torque e RPM na roda:

differential_ratio=3.42;

for i=1:1:5
    tau_wheel(i,:)=differential_ratio*gear_ratios(i).*torque_engine;
    rpm_wheel(i,:)=rpm./(gear_ratios(i)*differential_ratio);
    plot(rpm_wheel(i,:),tau_wheel(i,:))
    hold on
end

%%
clear all
rpm=[500,1800,2000,2200,2400,2600,2800,3000,3200,3400,3600,3800,4000,4200,4400,4600,4800,5000,5200,5400,5600,5800];
torque_engine_lbf=[320,325,330,340,350,355,357,359,360,360,362,363,363,362,360,355,350,345,340,327,320,310];

torque_engine=torque_engine_lbf.*1.35582;
gear_ratios=[3.54,2.13,1.36,1.03,0.72];
plot(rpm,torque_engine,'c')
colors=['r','g','b','k','m'];
hold on
for i=1:1:5
    torque(i,:)=gear_ratios(i).*torque_engine;
    plot(rpm,torque(i,:),colors(i))
    hold on
end
hold off


%% Testes Interpolação Linear:

rpm=[500,1800,2000,2200,2400,2600,2800,3000,3200,3400,3600,3800,4000,4200,4400,4600,4800,5000,5200,5400,5600,5800];
torque_engine_lbf=[320,325,330,340,350,355,357,359,360,360,362,363,363,362,360,355,350,345,340,327,320,310];
torque_engine=torque_engine_lbf.*1.35582;
desired_rpm=2350

if (desired_rpm>rpm(1))&&(desired_rpm<rpm(size(rpm,2)))
    for i=1:1:size(rpm,2)
        if rpm(i)>desired_rpm
            xb=rpm(i);
            xa=rpm(i-1);
            yb=torque_engine(i);
            ya=torque_engine(i-1);
            y=ya+(yb-ya)*((desired_rpm-xa)/(xb-xa));
            break
        end
    end
end

%%


clear all
rpm=[500,1800,2000,2200,2400,2600,2800,3000,3200,3400,3600,3800,4000,4200,4400,4600,4800,5000,5200,5400,5600,5800];
torque_engine_lbf=[320,325,330,340,350,355,357,359,360,360,362,363,363,362,360,355,350,345,340,327,320,310];
colors=['r','g','b','k','m'];
torque_engine=torque_engine_lbf.*1.35582;
gear_ratios=[3.54,2.13,1.36,1.03,0.72];

wheel_radius=0.34;
differential_ratio=3.42;
hold on
for i=1:1:5
    %torque(i,:)=gear_ratios(i).*torque_engine;
    v(i,:)=convert_ms_to_kmhr((rpm.*(2*pi*wheel_radius))./(gear_ratios(i)*60*differential_ratio));
    plot(rpm,v(i,:),colors(i))
    hold on
end





















