Extracting natural frequencies and mode shapes from a Simscape Multibody model
0 Kommentare
Antworten (2)
0 Kommentare
Hi @Edward Yap,
I went through your comments and wanted to provide some additional detail on the linearization approach that might help you get the modal properties you need for validation.
For your first comment about extracting modal properties like eigenvalues and eigenvectors to compute natural frequencies and mode shapes, you're correct that Simscape Multibody keeps the equations of motion as a black box. The equations are formulated and symbolically reduced internally and aren't exposed to users. However, the linearization approach can work well if you set it up properly with attention to a few important details. Here's a more complete workflow:
% Your model name mdl = 'your_model_name';
% Update the model to ensure it's compiled set_param(mdl, 'SimulationCommand', 'update');
% Get linearization I/O points sys_io = getlinio(mdl);
% Linearize the model at equilibrium (initial conditions should be at rest) linsys = linearize(mdl, sys_io);
% Extract state-space matrices [A, B, C, D] = ssdata(linsys);
% Get state names to understand ordering state_names = linsys.StateName;
% Compute eigenvalues and eigenvectors [V, D] = eig(A); eigenvalues = diag(D);
% Extract natural frequencies from eigenvalues % For undamped systems, eigenvalues come in pairs: ±iω % For damped systems: -ζωn ± iωd natural_freq_rad = abs(eigenvalues); % rad/s natural_freq_hz = natural_freq_rad / (2*pi); % Hz
% Find unique natural frequencies (remove conjugate pairs) [unique_freqs, idx] = unique(round(natural_freq_hz, 4)); unique_freqs = unique_freqs(unique_freqs > 1e-6); % Remove near-zero modes
% Display results
disp('Natural Frequencies (Hz):');
disp(unique_freqs);
The key detail for extracting mode shapes is understanding the state ordering. Simscape typically orders states as [positions; velocities], so the eigenvectors need to be interpreted in that context. The position components of the eigenvectors represent your mode shapes:
% Find position states (usually first half of states) n_states = length(state_names); n_dof = n_states / 2;
% Extract mode shapes from eigenvectors % For each mode (eigenvalue pair), take position components mode_shapes = []; natural_freqs_list = [];
for i = 1:2:n_states % Step by 2 to skip conjugate pairs
if abs(imag(eigenvalues(i))) > 1e-6 % Check if it's an oscillatory mode
% Extract position components from eigenvector
mode_shape = real(V(1:n_dof, i));
% Normalize
mode_shape = mode_shape / max(abs(mode_shape));
mode_shapes = [mode_shapes, mode_shape];
natural_freqs_list = [natural_freqs_list; natural_freq_hz(i)];
end
end
% Plot mode shapes
figure;
for i = 1:size(mode_shapes, 2)
subplot(ceil(size(mode_shapes,2)/2), 2, i);
bar(mode_shapes(:, i));
title(sprintf('Mode %d: %.2f Hz', i, natural_freqs_list(i)));
xlabel('DOF Index');
ylabel('Normalized Amplitude');
end
If you need undamped modal analysis for clearer results, set damping to zero in your joint or spring-damper blocks before linearizing.
For your second comment about whether there's a specific block in Simscape R2019a for modal analysis, unfortunately no, there wasn't one available at that time. The Reduced Order Flexible Solid block that can work with mass and stiffness matrices from FEA software wasn't added until R2019b (after your question). So for R2019a, the linearization approach is your best option.There's also a helpful File Exchange library called "Flexible Body Models in Simscape Multibody" by Steve Miller that includes working examples of this exact workflow. The library contains a complete script called sm_flex_lumped_param_beam_calculate_modes.m that demonstrates:
- Setting damping to zero for modal calculation
- Getting the proper state order from Simscape blocks
- Linearizing the model
- Extracting eigenvalues and computing natural frequencies
- Reconstructing mode shapes from eigenvectors
- Plotting the mode shapes
The script includes helper functions to properly map eigenvector components back to physical coordinates, which is really helpful for visualizing mode shapes in a meaningful way. Here's the general pattern from that library:
% 1. Configure model for modal analysis (zero damping) % Set damping parameters to 0 in your blocks
% 2. Get state ordering from your Simscape structure % This helps map eigenvector components to physical DOFs
% 3. Linearize with proper configuration linsys = linearize(mdl, sys_io);
% 4. Eigenvalue decomposition [V, D] = eig(linsys.A);
% 5. Extract position state components from eigenvectors % Use state ordering to identify which components are positions
% 6. Visualize mode shapes % Plot the position components for each mode
The library provides battle-tested code that handles all the nuances of state ordering and eigenvector interpretation, so it's worth checking out if you want a reference implementation.
References:
1. MathWorks Forum - "Can Simscape Multibody or Simscape Driveline generate automatically the dynamic equations of motion?" - Confirms that equations are kept internal ( https://www.mathworks.com/matlabcentral/answers/339715 )
2. MathWorks File Exchange - "Flexible Body Models in Simscape Multibody" by Steve Miller - Contains working modal analysis scripts ( https://www.mathworks.com/matlabcentral/fileexchange/47051 )
3. GitHub Repository - Simscape-Multibody-Flex-Beam - Contains source code with complete modal analysis implementation ( https://github.com/mathworks/Simscape-Multibody-Flex-Beam )
4. MathWorks Documentation - "Linearize Simscape Networks" - Explains proper linearization workflow ( https://www.mathworks.com/help/slcontrol/ug/linearize-simscape-networks.html )
5. MathWorks Forum - "Can equations of motion generated in MATLAB Simscape Multibody be extracted" - Additional discussion on the black box nature ( https://www.mathworks.com/matlabcentral/answers/378622 )
Hope this gives you a more complete picture of how to extract the modal properties you need for your validation work. The key is really in understanding the state ordering and properly interpreting the eigenvectors.
0 Kommentare
Siehe auch
Kategorien
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!