changing range of calculations
2 views (last 30 days)
Show older comments
Hello,
I've tried to change the following program until m=5 , n=5, p=5 rather than 4 . The error that I find while changing the matrix n or m is : Dimensions of arrays being concatenated are not consistent . Can you help me please? Thanks a lot.
function Frequencia_Table = Frequencia(v,lx,ly,lz)
% Building the array of values
m = [zeros(5,1); repelem([1:4]',6,1)];
n = [0; repmat(repelem([1 2 0]',2,1),4,1); 1; 1; 2; 2];
p = [repmat([1;0],14,1); 1];
Freq = [m, n, p, nan(size(m,1),1)];
v=3.*1e8;
% Function handle
f = @(lx,lz,ly) v/2.*sqrt((m./lx).^2 + (n./ly).^2 + (p./lz).^2);
%Calculate Frequencies (lx = 2, ly = 3, lz = 4) --> Enter the lengths here
lx=2;
ly=3;
lz=4;
Freq(:,4) = f(lx,lz,ly);
% Create a table of the results
Frequencia_Table = table(Freq(:,1),Freq(:,2),Freq(:,3),Freq(:,4),'VariableNames',{'m','n','p','Frequencia'});
end
0 Comments
Answers (1)
Walter Roberson
on 29 May 2021
function Frequencia_Table = Frequencia(v,lx,ly,lz)
% Building the array of values
maxval = 5;
m = [zeros(5,1); repelem([1:maxval]',6,1)];
n = repmat([0;0;1;1;2;2], maxval+1, 1);
n = n(2:end);
p = repmat([1;0],(maxval+1)*3,1);
p = p(2:end);
Freq = [m, n, p, nan(size(m,1),1)];
v=3.*1e8;
% Function handle
f = @(lx,lz,ly) v/2.*sqrt((m./lx).^2 + (n./ly).^2 + (p./lz).^2);
%Calculate Frequencies (lx = 2, ly = 3, lz = 4) --> Enter the lengths here
lx=2;
ly=3;
lz=4;
Freq(:,4) = f(lx,lz,ly);
% Create a table of the results
Frequencia_Table = table(Freq(:,1),Freq(:,2),Freq(:,3),Freq(:,4),'VariableNames',{'m','n','p','Frequencia'});
end
See Also
Categories
Find more on Data Type Identification 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!