Buckets:
| % ...existing code... | |
| % Interface et tracés : phi(x) sur [0,l] et U(t) pour un mode 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 | |
| % Choix du mode | |
| modeStr = inputdlg(sprintf('Choisir un mode entier entre 1 et %d :', nmodes), 'Mode', 1, {'1'}); | |
| if isempty(modeStr) | |
| disp('Sélection du mode annulée. Fin.'); | |
| return | |
| end | |
| modeIdx = round(str2double(modeStr{1})); | |
| if isnan(modeIdx) || modeIdx < 1 || modeIdx > nmodes | |
| error('Indice de mode invalide. Doit être entier entre 1 et %d.', nmodes); | |
| end | |
| % Calcul de phi(x) continu sur [0,l] et valeur en Xsel | |
| x_cont = linspace(0, l, 500); | |
| phi_cont = D * sin(omega(modeIdx) * x_cont / c); % phi(x) pour le mode choisi | |
| phi_at_X = D * sin(omega(modeIdx) * Xsel / c); % phi en Xsel | |
| % Déplacement temporel U(t) pour ce mode au point Xsel | |
| U_t = A(modeIdx) * phi_at_X * sin(omega(modeIdx) * t); | |
| % Tracés | |
| figure('Name', sprintf('Mode %d en X=%.3fm', modeIdx, Xsel), 'NumberTitle','off'); | |
| % 1) phi(x) sur [0,l] | |
| subplot(1,2,1); | |
| plot(x_cont, phi_cont, 'b-', 'LineWidth', 1.6); | |
| hold on; | |
| plot(Xsel, phi_at_X, 'ro', 'MarkerSize', 8, 'LineWidth', 1.6); | |
| xlabel('x (m)'); | |
| ylabel('\phi(x)'); | |
| title(sprintf('Forme du mode %d', modeIdx)); | |
| legend(sprintf('\\phi_{mode %d}(x)', modeIdx), sprintf('X = %.3f m', Xsel), 'Location', 'best'); | |
| grid on; | |
| hold off; | |
| % 2) U(t) pour le mode au point choisi | |
| subplot(1,2,2); | |
| plot(t, U_t, 'k-', 'LineWidth', 1.4); | |
| xlabel('t (s)'); | |
| ylabel('U(t)'); | |
| title(sprintf('U(t) — mode %d en X = %.3f m', modeIdx, Xsel)); | |
| grid on; | |
| % Affichage résumé | |
| fprintf('Affichage réalisé : mode = %d, X = %.3f m\n', modeIdx, Xsel); | |
| % ...existing code... | |
| % Interface et tracés : phi(x) sur [0,l] et U(t) pour un mode en un point X choisi | |
Xet Storage Details
- Size:
- 2.84 kB
- Xet hash:
- 5e31bb65cdf858b0123184c8a1d9dcd1cbb875b33e8f1606d89c8327bf2963e5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.