diff --git a/missions/2024_Lyra_Portugal_October/coeffs.mat b/missions/2024_Lyra_Portugal_October/coeffs.mat new file mode 100644 index 0000000000000000000000000000000000000000..9541fa12a71eee690e5058a13d0776f49a2e4128 --- /dev/null +++ b/missions/2024_Lyra_Portugal_October/coeffs.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03cad263bc9df04c4d66ca96dd5bd8e8e296c19efdfbaf80d3f696401938bdc4 +size 44352141 diff --git a/missions/matConverter.m b/missions/matConverter.m new file mode 100644 index 0000000000000000000000000000000000000000..5e706f69a62e3361d214071e679b8f7f6b103243 --- /dev/null +++ b/missions/matConverter.m @@ -0,0 +1,72 @@ +%%% conversion script form MSA data to PRP data +clear +clc +close all + +%% path +mission = '2024_Lyra_Portugal_October'; +coeffPath = fullfile(fileparts(mfilename("fullpath")), mission, 'data', 'aeroCoefficients.mat'); +insideMat = who('-file', coeffPath); + +prpPath = fullfile(fileparts(mfilename("fullpath")), mission, 'coeffs.mat'); + +if ~isfile(prpPath) + disp('coeffs.mat does not exist. Creating a new file...'); + coeffs_struct = struct(); + save(prpPath, "coeffs_struct"); +end + +%% qstdlg drop-down +[selectedVar, ok] = listdlg('PromptString', 'Select a motor to load:', ... + 'SelectionMode', 'single', ... + 'ListString', insideMat, ... + 'Name', 'Motor Selection'); + +% Check if a selection was made +if ok + chosenVar = insideMat{selectedVar}; + load(coeffPath, '-mat', chosenVar); % Load the chosen variable + disp(['Loaded motor: ', chosenVar]); +else + disp('No motor selected.'); +end + +%% load +load(coeffPath, "-mat", chosenVar); +disp(['PATH: ',coeffPath]) + +motor_struct = eval(chosenVar); + +%% change fields names +coeffs_struct = changeFieldsNames(motor_struct); + +%% save +save(prpPath,'-struct', 'coeffs_struct') +disp('Motor data saved to coeffs.mat') +disp(['PATH: ',prpPath]) + +%% function change fields names +function coeffs_struct = changeFieldsNames(motor_struct) + StateFields = {'Alphas', 'Altitudes', 'Betas', 'Machs', 'hprot', 'xcgTime'}; + startingStateFields = fields(motor_struct.state)'; + + for i = 1:length(StateFields) + StateName = string(StateFields(i)); + startingStateName = string(startingStateFields(i)); + coeffs_struct.State.(StateName)= motor_struct.state.(startingStateName); + end + + coeffs_struct.CoeffsTot = motor_struct.total; + + GeometryFields = {'Chord1', 'Chord2', 'Height', 'deltaXLE', 'C', 'Lnose', ... + 'Lcenter', 'Npanel', 'OgType', 'boatL', 'boatD', 'boatType', 'cMod', 'pMod', 'xcg'}; + startingGeometryFields = fields(motor_struct.geometry)'; + + for i = 1:length(GeometryFields) + GeometryName = string(GeometryFields(i)); + startingGeometryName = string(startingGeometryFields(i)); + coeffs_struct.Geometry.(GeometryName)= motor_struct.geometry.(startingGeometryName); + end + coeffs_struct.Geometry.xcgf = motor_struct.geometry.(startingGeometryName)(1); + coeffs_struct.Geometry.xcge = motor_struct.geometry.(startingGeometryName)(end); +end \ No newline at end of file