Your code can be vectorized to:
c = 344;
w = 2.20;
L = 3.50;
h = 3.02;
n = 1:9;
fL = c/2 .* n/L;
fw = c/2 .* n/w;
fh = c/2 .* n/h;
nL = 1:4;
nw = 1:4;
nh = 1:4;
fLw = c/2 * sqrt(bsxfun(@plus, (nL.'/L).^2, (nw/w).^2));
fwh = c/2 * sqrt(bsxfun(@plus, (nw.'/w).^2, (nh/h).^2));
fLh = c/2 * sqrt(bsxfun(@plus, (nL.'/L).^2, (nh/h).^2));
fLwh = c/2 * sqrt(bsxfun(@plus,(fLw(1:2,1:2) * 2/c).^2, permute(nh(1:2)/h,[3 1 2]).^2));
- In your previous code you didn't preallocate correctly for the tangential modes and oblique ones.
- Also the fLh depends on nL and nh but its calculation is nested into the loop for nw as well, which means that you calculate it several times redundantly overwrtiting the same results.
Now the MAIN question:
- Do you want fL,fw,fh,fLw,fwh,fLh and fLwh all together sorted?
EDIT
[srt, idx] = sort([fL(:);fw(:);fh(:);fLw(:);fwh(:);fLh(:);fLwh(:)])
Best Answer