Set different properties using for loop

4 views (last 30 days)
Jose
Jose on 28 Sep 2022
Commented: Adam Danz on 28 Sep 2022
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 Comments
Adam Danz
Adam Danz on 28 Sep 2022
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.

Sign in to comment.

Answers (1)

David Hill
David Hill on 28 Sep 2022
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

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!