run_config_forget_other_sen.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. function [res] = run_config_forget_other_sen(varargin)
  2. if nargin == 0
  3. file_name = "default_config.json";
  4. elseif nargin == 1
  5. file_name = varargin{1};
  6. else
  7. file_name = varargin{1};
  8. warning("run_config only accepts one argument. Every other argument is ignored")
  9. end
  10. config = jsondecode(fileread(file_name));
  11. methods = config.calibrationMethods;
  12. iter_max = round(config.Tmax / config.delta_measure);
  13. RMSEs = cell(length(methods),1+config.numSubSensor);
  14. times = cell(length(methods),1);
  15. for run = 1:config.numRuns
  16. % data generation
  17. [X, X_theo, W, F_theo, Omega_G, Omega_F, Phi_G, Phi_F, Ginit, Finit] = data_gen(config, run);
  18. seed = floor(rand*10000);
  19. % We want to only calibrate the sensor of interest
  20. % X = X(:,1:config.numSensor+1);
  21. % X_theo = X_theo(:,1:config.numSensor+1);
  22. % W = W(:,1:config.numSensor+1);
  23. % F_theo = F_theo(:,1:config.numSensor+1);
  24. % Omega_F = Omega_F(:,1:config.numSensor+1);
  25. % Phi_F = Phi_F(:,1:config.numSensor+1);
  26. % Finit = Finit(:,1:config.numSensor+1);
  27. X = X(:,1:config.numSensor+1);
  28. X_theo = X_theo(:,1:config.numSensor+1);
  29. W = W(:,1:config.numSensor+1);
  30. F_theo = F_theo(1:2,1:config.numSensor+1);
  31. Omega_F = Omega_F(1:2,1:config.numSensor+1);
  32. Phi_F = Phi_F(1:2,1:config.numSensor+1);
  33. Finit = Finit(1:2,1:config.numSensor+1);
  34. Omega_G = Omega_G(:,1:2);
  35. Phi_G = Phi_G(:,1:2);
  36. Ginit = Ginit(:,1:2);
  37. config.numSubSensor = 1;
  38. % Testing each method for the same data
  39. for it_meth = 1:length(methods)
  40. rng(seed) % resetting the seed before starting the method
  41. fct = str2func(methods{it_meth});
  42. [T, RMSE , MERs] = fct(X, X_theo, W, F_theo, Omega_G, Omega_F, Phi_G, Phi_F, Ginit, Finit, config);
  43. times{it_meth} = T; % overwritting previous record times for simplicity's sake
  44. % figure
  45. for measure = 1:(1+config.numSubSensor)
  46. RMSEs{it_meth,measure} = cat(1, RMSEs{it_meth,measure}, RMSE(measure,:)); % saving the RMSE
  47. % % RMSEs{it_meth,1} is for the offsets, RMSEs{it_meth,>1} is
  48. % % for the gains
  49. % plot(MERs(measure,:))
  50. % hold on
  51. end
  52. end
  53. end
  54. if config.display
  55. figure
  56. for it_meth = 1:length(methods)
  57. for measure = 1:(config.numSubSensor+1)
  58. subplot(length(methods),config.numSubSensor+1,(it_meth-1)*(config.numSubSensor+1)+measure)
  59. for k = 1:size(RMSEs{it_meth,measure},1)
  60. semilogy(RMSEs{it_meth,measure}(k,:))
  61. hold on
  62. end
  63. hold off
  64. end
  65. end
  66. end
  67. end