- what conditions define each set of values?
- do you have 380 objects in which you are applying one of two sets of values?
Set different properties using for loop
1 次查看(过去 30 天)
显示 更早的评论
Hi, I'm modelling an adsorber bed and I need to set two different materials.
I have basic notions of programming and I would do it like this:
L=3.8
nz=380
z=linspace(0,L,Nz);
%Activated alumina first
for z=1:41
epsb=0.26; %bed porosity
dp=5E-3; %activated alumina diameter
tau=3.6; %tortuosity
rpore=4.5E-9; %pore radius
ep=0.28; %particle porosity
rhop=820; %particule density
else
epsb=0.4; %bed porosity
dp=2.7E-3; %Zeolite 13x-APG diameter
tau=4; %tortuosity
rpore=6.25E-10; %pore radius
ep=0.3; %particle porosity
rhop=1099.5; %particule density
end
I'd appreciate your help
3 个评论
Adam Danz
2022-9-28
I don't have enough background info on what you're doing or how the variables in your quesitons are applied to your model.
Perhaps each variable could be a 1x2 vector where var(1) value of propery var is applied to one material and var(2) applied to the other material.
回答(1 个)
David Hill
2022-9-28
Recommend a lookup table for the material. Then just index into when data is needed.
matLookup=[0.26,5E-3,3.6,4.5E-9,0.28,820;...
0.4,2.7E-3,4,6.25E-10,0.3,1099.5];
L=3.8
nz=380
z=linspace(0,L,Nz);
for z=1:numel(z)
idx=ismember(z,[1 5 7 9 11 17])+1;%conditional for zeolite
%do some calculations
N(z)=matLookup(idx,1)*matLookup(idx,5)/matLookup(idx,3);
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quaternion Math 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!