clear

%% load network
% loaded_net=load("NLD_network_polar_01_log_mvm_c1_05.mat");
% loaded_net=load("NLD_network_minmax_c1_05.mat");
% loaded_net=load("NLD_network_polar_01_c1_05.mat");
% loaded_net=load("NLD_network_polar_01_mvm_c1_05.mat");
loaded_net=load("NLD_network_polar_01_log_c1_05.mat");

net=loaded_net.net;
clear("loaded_net"); % eliminate useless data from workspace


%% load and test NLD

loaded_testdata=load("NLD_4incremental_testing_polar_01_log_mvm_c1_01.mat");
rho=loaded_testdata.rho;
c3=loaded_testdata.c3;
c3cr=loaded_testdata.c3cr;
clear("loaded_testdata"); % eliminate useless data from workspace

pred = classify(net, rho);

figure;plot(c3,pred,'.');hold on;
plot(c3cr*ones(2,1),[3 1],'r-');axis tight


%% load and test VDP

% loaded_testdata=load("VDP_4incremental_testing_polar_01_log_mvm.mat");
% loaded_testdata=load("VDP_4incremental_testing_minmax.mat");
% loaded_testdata=load("VDP_4incremental_testing_polar_01.mat");
% loaded_testdata=load("VDP_4incremental_testing_polar_01_mvm.mat");
loaded_testdata=load("VDP_4incremental_testing_polar_01_log.mat");

rho1=loaded_testdata.rho1;
rho2=loaded_testdata.rho2;
mu1=loaded_testdata.mu1;
mu1cr=0.0619;
clear("loaded_testdata"); % eliminate useless data from workspace

pred1 = classify(net, rho1);
pred_num1 = str2double(cellstr(pred1));

pred2 = classify(net, rho2);
pred_num2 = str2double(cellstr(pred2));


set(groot,'defaultAxesTickLabelInterpreter','latex');

figure;subplot(211);
plot(mu1(find(pred_num1==3)),pred_num1(find(pred_num1==3)),'.','MarkerSize',6);hold on;
plot(mu1(find(pred_num1==2)),pred_num1(find(pred_num1==2)),'r.','MarkerSize',6);
plot(mu1(find(pred_num1==1)),pred_num1(find(pred_num1==1)),'g.','MarkerSize',6);
plot(mu1cr*ones(2,1),[3.5 0.5],'k--','LineWidth',2);
xlim([0.02 0.07])
ylim([0.7 3.3])

subplot(212);
plot(mu1(find(pred_num2==3)),pred_num2(find(pred_num2==3)),'.','MarkerSize',6);hold on;
plot(mu1(find(pred_num2==2)),pred_num2(find(pred_num2==2)),'r.','MarkerSize',6);
plot(mu1(find(pred_num2==1)),pred_num2(find(pred_num2==1)),'g.','MarkerSize',6);
plot(mu1cr*ones(2,1),[3.5 0.5],'k--','LineWidth',2);
xlim([0.02 0.07])
ylim([0.7 3.3])

%% load and test MOB

% loaded_testdata=load("MOB_4incremental_testing_polar_01_log_mvm.mat");
% loaded_testdata=load("MOB_4incremental_testing_minmax.mat");
% loaded_testdata=load("MOB_4incremental_testing_polar_01.mat");
% loaded_testdata=load("MOB_4incremental_testing_polar_01_mvm.mat");
loaded_testdata=load("MOB_4incremental_testing_polar_01_log.mat");
% rho=loaded_testdata.rho1;
rho=loaded_testdata.rho1;
v=loaded_testdata.v;
vcr=loaded_testdata.vcr;
clear("loaded_testdata"); % eliminate useless data from workspace

pred = classify(net, rho);
pred_num = str2double(cellstr(pred));


set(groot,'defaultAxesTickLabelInterpreter','latex'); 
figure;
plot(v(find(pred_num==3)),pred_num(find(pred_num==3)),'.','MarkerSize',6);hold on;
plot(v(find(pred_num==2)),pred_num(find(pred_num==2)),'r.','MarkerSize',6);
plot(v(find(pred_num==1)),pred_num(find(pred_num==1)),'g.','MarkerSize',6);
plot(vcr*ones(2,1),[3.5 0.5],'k--','LineWidth',2);
xlim([1.3 2.4])
ylim([0.7 3.3])

%% load and test PnP

% loaded_testdata=load("PnP_4incremental_testing_polar_01_log_mvm.mat");
% loaded_testdata=load("PnP_4incremental_testing_minmax.mat");
% loaded_testdata=load("PnP_4incremental_testing_polar_01.mat");
% loaded_testdata=load("PnP_4incremental_testing_polar_01_mvm.mat");
loaded_testdata=load("PnP_4incremental_testing_polar_01_log.mat");
rho1=loaded_testdata.rho1;
rho2=loaded_testdata.rho2;
u=loaded_testdata.u;
ucr=loaded_testdata.ucr;
clear("loaded_testdata"); % eliminate useless data from workspace

pred1 = classify(net, rho1);
pred_num1 = str2double(cellstr(pred1));

pred2 = classify(net, rho2);
pred_num2 = str2double(cellstr(pred2));


set(groot,'defaultAxesTickLabelInterpreter','latex');

figure;subplot(211);
plot(u(find(pred_num1==3)),pred_num1(find(pred_num1==3)),'.','MarkerSize',6);hold on;
plot(u(find(pred_num1==2)),pred_num1(find(pred_num1==2)),'r.','MarkerSize',6);
plot(u(find(pred_num1==1)),pred_num1(find(pred_num1==1)),'g.','MarkerSize',6);
plot(ucr*ones(2,1),[3.5 0.5],'k--','LineWidth',2);
xlim([0.83 0.97])
ylim([0.7 3.3])

subplot(212);
plot(u(find(pred_num2==3)),pred_num2(find(pred_num2==3)),'.','MarkerSize',6);hold on;
plot(u(find(pred_num2==2)),pred_num2(find(pred_num2==2)),'r.','MarkerSize',6);
plot(u(find(pred_num2==1)),pred_num2(find(pred_num2==1)),'g.','MarkerSize',6);
plot(ucr*ones(2,1),[3.5 0.5],'k--','LineWidth',2);
xlim([0.83 0.97])
ylim([0.7 3.3])



