diff --git a/autoMatricesProtub/mainAutoMatProtub.m b/autoMatricesProtub/mainAutoMatProtub.m index 86cc083a024b5eed0d785d95ccaf372920fa5674..ad85f77314cd2613799be1050520bcfbee2865a7 100644 --- a/autoMatricesProtub/mainAutoMatProtub.m +++ b/autoMatricesProtub/mainAutoMatProtub.m @@ -37,17 +37,24 @@ end %% CHOICE OF NUMBER OF XCG timeXcgTotal = rocket.motor.time; xcgTotal = rocket.xCg; +nXcg = autoMatSettings.vars.Nxcg; -% Decisional figure -h = figure('Name', 'XCG DECISION', 'NumberTitle', 'off'); -plot(timeXcgTotal, xcgTotal); grid on; hold on -title('Weighted XCG'); xlabel('Time [s]'); ylabel('XCG [m]'); -chosenXcg = xcgTotal(floor(linspace(1, length(xcgTotal), autoMatSettings.vars.Nxcg))); % xcg where to create the matrices -xcgTime = timeXcgTotal(floor(linspace(1, length(timeXcgTotal), autoMatSettings.vars.Nxcg))); % times where we create the matrices -plot(xcgTime, chosenXcg, 'ro', 'MarkerFaceColor', 'r', 'MarkerSize', 4); -plot(xcgTime, chosenXcg, 'b--'); -legend('Xcg variation', 'Xcg wanted', 'Linear interpolation'); -hold off +if nXcg == 1 + chosenXcg = xcgTotal(1); +else + % Decisional figure + h = figure('Name', 'XCG DECISION', 'NumberTitle', 'off'); + plot(timeXcgTotal, xcgTotal); grid on; hold on + title('Weighted XCG'); xlabel('Time [s]'); ylabel('XCG [m]'); + + xcgTime = linspace(timeXcgTotal(1), timeXcgTotal(end), nXcg); % times where we create the matrices + chosenXcg = interp1(timeXcgTotal, xcgTotal, xcgTime); % xcg where to create the matrices + + plot(xcgTime, chosenXcg, 'ro', 'MarkerFaceColor', 'r', 'MarkerSize', 4); + 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."),...