How to find which equation produced a specific answer in a for loop?
Show older comments
I've used a for loop to calculate modal frequencies of a room.
close all;
clear all;
Lx = 8; % Set room dimensions (metres)
Ly = 5;
Lz = 4;
c = 343; % Speed of sound
num_mx = 10; % End modenumbers to calculate
num_my = 10;
num_mz = 10;
i=0;
for mx = 0:num_mx % First we need to generate a vector of modal frequencies
for my = 0:num_my
for mz = 0:num_mz
i=i+1;
freq(i) = c*sqrt((mx/(2*Lx))^2 + (my/(2*Ly))^2 + (mz/(2*Lz))^2);
% frequency of mode
end % mz
end % my
end % mx
fsorted = sort(freq); % sort the modal frequencies
fsorted(2:22) % display 20 lowest modes
I need to find which values of mx, my and mz produced the 20 lowest values i've sorted at the end but can't figure out how, any help would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!