how to use technique to save value in final matrix - matlab coding?
1 次查看(过去 30 天)
显示 更早的评论
I have duct simulation parameter as following
Nmod = 5; % modes in duct 1 to 5
L = 1.2; % length of duct
K = 0.051; % impedance at one end
zi = 0.315;
zm = 0.775;
c = 340 ;
roh = 1.225;
S = 1;
eta =1 ;
betan = -(1:Nmod)*pi/L;
alfa = 1/(2*L)*log((1-K)/(1+K));
%****and formulas for matrices*******
Anr = c * [alfa betan; -betan alfa]; % formula for Anr matrices
Ani = c*eta*[1 0;0 1];
An = [Anr -Ani ; Ani Anr]; % Anr and Ani matrices pack in An
i want to do this simulation for Nmod = 5 times and save the An value for each mode 1,2,3,4,5 in final Ai matrix ?
how should i do this in matlab?
0 个评论
回答(1 个)
Pourya Alinezhad
2013-6-10
with a for loop you can write following code: for kk=1:Nmod {all your code goes here} Ai(kk)=An; end
so Ai(1) will hold An for Nmod=1 ,Ai(2) will hold An for Nmod=2 and so on....
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!