diff --git a/autoMatricesProtub/mainAutoMatProtub.m b/autoMatricesProtub/mainAutoMatProtub.m index 5257e59ae5bead73bfd3f5086181812ff009be37..cf618b4339dd0c62d9bb01565a1b4bc87a2d5481 100644 --- a/autoMatricesProtub/mainAutoMatProtub.m +++ b/autoMatricesProtub/mainAutoMatProtub.m @@ -39,8 +39,9 @@ timeXcgTotal = rocket.motor.time; xcgTotal = rocket.xcg; nXcg = autoMatSettings.vars.Nxcg; -if nXcg == 1 +if nXcg == 1 || ~rocket.dynamicDerivatives chosenXcg = xcgTotal(1); + autoMatSettings.vars.Nxcg = 1; else % Decisional figure h = figure('Name', 'XCG DECISION', 'NumberTitle', 'off'); @@ -54,28 +55,28 @@ else plot(xcgTime, chosenXcg, 'b--'); legend('Xcg variation', 'Xcg wanted', 'Linear interpolation'); hold off -end - -% Questlog -answer = questdlg({strcat("In the figure you can see the red dot where the xcg variation will be discretized."),... - " ", strcat("Choose a number of xcgs with which a linear interpolation can be a suitable approximation of xcg variation."),... - " ", strcat("Number of xcg wanted: ", num2str(autoMatSettings.vars.Nxcg)),... - " ",... - 'Do you want to proceed?'}, ... - 'Dialog', 'Yes', 'No', 'No'); -% Handle response -switch answer - case 'Yes' - close(h); - fprintf('Generating new coefficients...\n'); - case 'No' - close(h); - error('Routine run aborted') + % Questlog + answer = questdlg({strcat("In the figure you can see the red dot where the xcg variation will be discretized."),... + " ", strcat("Choose a number of xcgs with which a linear interpolation can be a suitable approximation of xcg variation."),... + " ", strcat("Number of xcg wanted: ", num2str(autoMatSettings.vars.Nxcg)),... + " ",... + 'Do you want to proceed?'}, ... + 'Dialog', 'Yes', 'No', 'No'); + + % Handle response + switch answer + case 'Yes' + close(h); + case 'No' + close(h); + error('Routine run aborted') + end end tic %% COMPUTE HIGH AOA AERODYNAMIC COEFFICIENTS +fprintf('Generating new coefficients: High AoA...\n'); autoMatSettings.varsHighAOA.xcg = rocket.xcg(end); if length(autoMatSettings.varsHighAOA.alpha) > 20 || ... length(autoMatSettings.varsHighAOA.mach) > 20 @@ -86,6 +87,7 @@ inputHighAOA = createDissileInput(rocket, autoMatSettings.varsHighAOA); [coeffsTotHighAOA, finsCNHighAOA] = dissileMatcom(inputHighAOA); %% COMPUTE AERODYNAMIC COEFFICIENTS +fprintf('Generating new coefficients: Refined envelope...\n'); autoMatSettings.vars.xcg = chosenXcg; if length(autoMatSettings.vars.alpha) > 20 || ... length(autoMatSettings.vars.mach) > 20 @@ -98,9 +100,9 @@ input = createDissileInput(rocket, autoMatSettings.vars); %% SAVE DATA if options.saveVars saveVars(autoMatSettings.varsHighAOA, rocket, mission, coeffsTotHighAOA, finsCNHighAOA, ... - chosenXcg, xcgTime, autoMatSettings.saveFinsCN, 'aeroCoefficientsHighAOA.mat'); + chosenXcg, autoMatSettings.saveFinsCN, 'aeroCoefficientsHighAOA.mat'); saveVars(autoMatSettings.vars, rocket, mission, coeffsTot, finsCN, ... - chosenXcg, xcgTime, autoMatSettings.saveFinsCN, 'aeroCoefficients.mat'); + chosenXcg, autoMatSettings.saveFinsCN, 'aeroCoefficients.mat'); end AMtime = toc; diff --git a/autoMatricesProtub/src/saveVars.m b/autoMatricesProtub/src/saveVars.m index 3aa3d99659f2b415d8c687de54e36e452a236ef2..3681975c383587d1ddd319e270e66315ff765d89 100644 --- a/autoMatricesProtub/src/saveVars.m +++ b/autoMatricesProtub/src/saveVars.m @@ -1,4 +1,4 @@ -function saveVars(vars, rocket, mission, total, finsCN, chosenXcg, xcgTime, saveFinsCN, outputName) +function saveVars(vars, rocket, mission, total, finsCN, chosenXcg, saveFinsCN, outputName) arguments vars @@ -7,7 +7,6 @@ arguments total finsCN chosenXcg - xcgTime saveFinsCN outputName end @@ -18,7 +17,6 @@ state.altitudes = vars.alt; state.betas = vars.beta; state.machs = vars.mach; state.hprot = vars.hprot; -state.xcgTime = xcgTime; %% GEOMETRY STRUCT geometry.chord1 = rocket.rear.finsRootChord; @@ -58,15 +56,19 @@ else save(outputPath, '-struct', 'output', '-append') end -output.(rocket.motor.name) = struct(); -output.(rocket.motor.name).state = state; -output.(rocket.motor.name).total = total; -output.(rocket.motor.name).geometry = geometry; -output.(rocket.motor.name).finsCN = []; +if rocket.dynamicDerivatives, fieldName = rocket.motor.name; + else, fieldName = 'generic'; +end + +output.(fieldName) = struct(); +output.(fieldName).state = state; +output.(fieldName).total = total; +output.(fieldName).geometry = geometry; +output.(fieldName).finsCN = []; if saveFinsCN finsCN = squeeze(finsCN(1, :, :, :, :, :)); % Consider only the first xcg bc fins CN is xcg-independent - output.(rocket.motor.name).finsCN = finsCN; + output.(fieldName).finsCN = finsCN; end save(outputPath, '-struct', 'output', '-append')