clc; close all; clear; 

% Load result tables
load('TAB_quad_rigida');
load('TAB_quad_flessibile');
load('TAB_semplice1');

% Numerical tolerances used to match fixed parameters
tolMap = containers.Map();
tolMap("Width [m]") = 1e-9;
tolMap("Slip ratio") = 1e-9;
tolMap("Velocity [m/s]") = 1e-9;
tolMap("Vehicle weight [kg]") = 1e-3;


%% CONTOUR PLOT
% Diameter vs Width, keeping the other variables fixed

fixed = containers.Map();

fixed("Slip ratio") = 0.2;
fixed("Velocity [m/s]") = 5;
fixed("Number of wheel") = 6;
fixed("Vehicle weight [kg]") = 7000;

contourSameOthers(TAB_quad_flessibile, ...
    "Diameter [m]", "Width [m]", "Drive power [W]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Diameter [m]", "Width [m]", "Total Motion resistance [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Diameter [m]", "Width [m]", "Maximum sinkage [m]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Diameter [m]", "Width [m]", "Drawbar pull [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");



%%
% Slip ratio vs Vehicle weight

fixed = containers.Map();

fixed("Diameter [m]") = 0.9;
fixed("Width [m]") = 0.4;
fixed("Velocity [m/s]") = 5;
fixed("Number of wheel") = 6;

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Vehicle weight [kg]", "Drive power [W]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Vehicle weight [kg]", "Drawbar pull [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Vehicle weight [kg]", "Total Motion resistance [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Vehicle weight [kg]", "Maximum sinkage [m]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

%%
% Velocity vs Number of wheels

fixed = containers.Map();

fixed("Diameter [m]") = 0.9;
fixed("Width [m]") = 0.4;
fixed("Vehicle weight [kg]") = 7000;
fixed("Slip ratio") = 0.2;

contourSameOthers(TAB_quad_flessibile, ...
    "Velocity [m/s]", "Number of wheel", "Drive power [W]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Velocity [m/s]", "Number of wheel", "Drawbar pull [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Velocity [m/s]", "Number of wheel", "Total Motion resistance [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Velocity [m/s]", "Number of wheel", "Maximum sinkage [m]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

%%
% Slip ratio vs Diameter

fixed = containers.Map();

fixed("Vehicle weight [kg]") = 7000;
fixed("Width [m]") = 0.4;
fixed("Velocity [m/s]") = 5;
fixed("Number of wheel") = 6;

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Diameter [m]", "Drive power [W]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Diameter [m]", "Drawbar pull [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Diameter [m]", "Total Motion resistance [N]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");

contourSameOthers(TAB_quad_flessibile, ...
    "Slip ratio", "Diameter [m]", "Maximum sinkage [m]", ...
    fixed, ...
    "Tol", tolMap, ...
    "Filled", true, "ShowPoints", true, "Method", "linear");