how to write correct looping
Show older comments
hi all
i want to read file and which is some condition
for data 1-100 is read properly
but i am confused why is the value in line X>99 i can not get rigth value
A=readfile('pf_ext_pcs_1_ts_1_t_1_000000_0.vtu')';
C = A(10217:13618);
C=cellfun(@(x)sscanf(x,'%f'),C,'UniformOutput',false);
format long g
pf=cell2mat(C); % 0 represents fracture occurs
pf(pf<0.1) =10000; %
km=nan(1000,1); % total cell permeability multiplier
a=1;
for x=1:10000
km(x,:)=1/8*(pf(x,1)+pf(x+1,1)+pf(200+a,1)+pf(201+a,1)+pf(10201+a,1)+pf(10202+a,1)+pf(a+10401,1)+pf(a+10402,1));
if x>99 &&x<199
km(x,:)=1/8*(pf(201-a,1)+pf(202-a,1)+pf(302-a,1)+pf(303-a,1)+pf(10402-a,1)+pf(10403-a,1)+pf(10503-a,1)+pf(10504-a,1));
elseif x > 199
km(x,:)=1/8*(pf(302-a,1)+pf(303-a,1)+pf(403-a,1)+pf(404-a,1)+pf(10503-a,1)+pf(10504-a,1)+pf(10604-a,1)+pf(10605-a,1));
elseif x > 299
km(x,:)=1/8*(pf(403-a,1)+pf(404-a,1)+pf(504-a,1)+pf(505-a,1)+pf(10604-a,1)+pf(10605-a,1)+pf(10705-a,1)+pf(10706-a,1));
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!