Buckets:
| % ...existing code... | |
| % Interface et tracés : phi(x) sur [0,l] et U(t) pour les modes en un point X choisi | |
| clearvars -except % garde workspace propre | |
| E = 210000; % MPa (ou unité cohérente) | |
| l = 1; % m | |
| rho = 7800; % kg/m^3 | |
| D = 1; % amplitude normalisée (utilisée pour phi) | |
| c = sqrt(E / rho); | |
| nmodes = 10; | |
| modes = 1:nmodes; | |
| omega = ((2*modes-1) * pi * c) / l; % pulsations (rad/s) | |
| A = 35 ./ omega; % amplitude non singulière (évite division par sin(...)=0) | |
| % Points proposés et temps | |
| X_choices = [l/4, l/2, 3*l/4, l]; | |
| t = linspace(0, 2*pi, 1000); % temps pour tracer U(t) | |
| % Choix du point X (liste + option valeur personnalisée si annulé) | |
| sel = listdlg('PromptString','Choisir un point X :', 'ListString', arrayfun(@(x) sprintf('X = %.3f m', x), X_choices, 'UniformOutput', false), 'SelectionMode','single'); | |
| if isempty(sel) | |
| answer = inputdlg('Entrez une valeur de X (en m) entre 0 et l :', 'X personnalisé', 1, {num2str(l/2)}); | |
| if isempty(answer) | |
| disp('Sélection X annulée. Fin.'); | |
| return | |
| end | |
| Xsel = str2double(answer{1}); | |
| if isnan(Xsel) || Xsel < 0 || Xsel > l | |
| error('Valeur de X invalide. Doit être dans [0, l].'); | |
| end | |
| else | |
| Xsel = X_choices(sel); | |
| end | |
| % Calcul des fonctions pour tous les modes | |
| x_cont = linspace(0, l, 500); | |
| % Figure 1: Les 10 premiers modes phi(x) en subplots | |
| figure('Name', 'Formes modales - 10 premiers modes', 'NumberTitle','off', 'Position', [100, 100, 1400, 900]); | |
| for modeIdx = 1:nmodes | |
| subplot(5, 2, modeIdx); % 5 lignes, 2 colonnes | |
| phi_cont = D * sin(omega(modeIdx) * x_cont / c); | |
| plot(x_cont, phi_cont, 'b-', 'LineWidth', 1.8); | |
| hold on; | |
| plot(Xsel, D * sin(omega(modeIdx) * Xsel / c), 'ro', 'MarkerSize', 6, 'LineWidth', 1.5); | |
| xlabel('x (m)'); | |
| ylabel('\phi(x)'); | |
| title(sprintf('Mode %d - \\omega = %.1f rad/s', modeIdx, omega(modeIdx))); | |
| grid on; | |
| % Ajouter une ligne à y=0 pour référence | |
| ylim_range = max(abs(phi_cont)) * 1.1; | |
| ylim([-ylim_range, ylim_range]); | |
| plot([0 l], [0 0], 'k--', 'LineWidth', 0.5); | |
| legend(sprintf('\\phi_{%d}(x)', modeIdx), sprintf('X = %.3f m', Xsel), 'Location', 'best'); | |
| end | |
| sgtitle('Formes modales spatiales - 10 premiers modes'); | |
| % Figure 2: Les 10 premiers modes U(t) au point X choisi en subplots | |
| figure('Name', sprintf('Déplacements temporels U(t) en X=%.3f m', Xsel), 'NumberTitle','off', 'Position', [100, 100, 1400, 900]); | |
| for modeIdx = 1:nmodes | |
| subplot(5, 2, modeIdx); % 5 lignes, 2 colonnes | |
| phi_at_X = D * sin(omega(modeIdx) * Xsel / c); | |
| U_t = A(modeIdx) * phi_at_X * sin(omega(modeIdx) * t); | |
| plot(t, U_t, 'r-', 'LineWidth', 1.6); | |
| xlabel('t (s)'); | |
| ylabel('U(t)'); | |
| title(sprintf('Mode %d - \\omega = %.1f rad/s', modeIdx, omega(modeIdx))); | |
| grid on; | |
| % Ajouter une ligne à y=0 pour référence | |
| ylim_range = max(abs(U_t)) * 1.1; | |
| if ylim_range > 0 | |
| ylim([-ylim_range, ylim_range]); | |
| end | |
| plot([min(t) max(t)], [0 0], 'k--', 'LineWidth', 0.5); | |
| legend(sprintf('U_{%d}(t) en X', modeIdx), 'Location', 'best'); | |
| end | |
| sgtitle(sprintf('Déplacements temporels en X = %.3f m - 10 premiers modes', Xsel)); | |
| % Affichage résumé | |
| fprintf('Affichage réalisé : X = %.3f m\n', Xsel); | |
| fprintf('Figures générées :\n'); | |
| fprintf('- 10 subplots des formes modales phi(x)\n'); | |
| fprintf('- 10 subplots des déplacements temporels U(t) au point X sélectionné\n'); | |
| % Optionnel: Afficher aussi les modes superposés pour comparaison | |
| choice = questdlg('Voulez-vous aussi afficher les modes superposés?', 'Modes superposés', 'Oui', 'Non', 'Non'); | |
| if strcmp(choice, 'Oui') | |
| % Figure 3: Modes superposés | |
| figure('Name', 'Comparaison des modes superposés', 'NumberTitle','off', 'Position', [100, 100, 1400, 600]); | |
| % Palette de couleurs pour les modes | |
| colors = lines(nmodes); | |
| subplot(1,2,1); | |
| hold on; | |
| for modeIdx = 1:nmodes | |
| phi_cont = D * sin(omega(modeIdx) * x_cont / c); | |
| plot(x_cont, phi_cont, 'LineWidth', 1.5, 'Color', colors(modeIdx,:), ... | |
| 'DisplayName', sprintf('Mode %d', modeIdx)); | |
| end | |
| xlabel('x (m)'); | |
| ylabel('\phi(x)'); | |
| title('Formes modales - Tous modes superposés'); | |
| legend('show', 'Location', 'eastoutside'); | |
| grid on; | |
| subplot(1,2,2); | |
| hold on; | |
| for modeIdx = 1:nmodes | |
| phi_at_X = D * sin(omega(modeIdx) * Xsel / c); | |
| U_t = A(modeIdx) * phi_at_X * sin(omega(modeIdx) * t); | |
| plot(t, U_t, 'LineWidth', 1.2, 'Color', colors(modeIdx,:), ... | |
| 'DisplayName', sprintf('Mode %d', modeIdx)); | |
| end | |
| xlabel('t (s)'); | |
| ylabel('U(t)'); | |
| title(sprintf('U(t) - Tous modes en X=%.3f m', Xsel)); | |
| legend('show', 'Location', 'eastoutside'); | |
| grid on; | |
| end | |
| % ...existing code... |
Xet Storage Details
- Size:
- 4.84 kB
- Xet hash:
- a46436d4bd1d92a57443926f23973aa7b40eb747b6b90d9bdb2a441b5188c43f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.