Set different properties using for loop

조회 수: 4(최근 30일)
Jose
Jose 2022년 9월 28일
댓글: Adam Danz 2022년 9월 28일
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
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
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

범주

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by