I want to print this statement 200 times using a loop or fprintf
2 views (last 30 days)
Show older comments
Please I want to repeat the below statement 200 times while always changing the indices at each level.
For Number 1:
WELL 'INJ_W001'
INJECTOR MOBWEIGHT 'INJ_W001'
INCOMP WATER
OPERATE MAX STW 5.087968e-006 CONT REPEAT
OPERATE MAX BHP 1000000.0 CONT REPEAT
PERF WI 'INJ_W001'
** UBA wi Status Connection
1 1 1 0.001 OPEN FLOW-FROM 'SURFACE'
**
For Number 2, I need the same statements but changing 1 to 2.
WELL 'INJ_W002'
INJECTOR MOBWEIGHT 'INJ_W002'
INCOMP WATER
OPERATE MAX STW 5.087968e-006 CONT REPEAT
OPERATE MAX BHP 1000000.0 CONT REPEAT
PERF WI 'INJ_W002'
** UBA wi Status Connection
1 2 1 0.001 OPEN FLOW-FROM 'SURFACE'
**
Lastly For Number 200,
WELL 'INJ_W200'
INJECTOR MOBWEIGHT 'INJ_W200'
INCOMP WATER
OPERATE MAX STW 5.087968e-006 CONT REPEAT
OPERATE MAX BHP 1000000.0 CONT REPEAT
PERF WI 'INJ_W200'
** UBA wi Status Connection
1 200 1 0.001 OPEN FLOW-FROM 'SURFACE'
**
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 7 Feb 2019
Edited: KALYAN ACHARJYA
on 7 Feb 2019
for i=1:200
fprintf('WELL INJ_W%d\n',i);
fprintf('INJECTOR MOBWEIGHT INJ_W%d\n',i);
disp('INCOMP WATER');
disp('OPERATE MAX STW 5.087968e-006 CONT REPEAT');
disp('OPERATE MAX BHP 1000000.0 CONT REPEAT');
fprintf('PERF WI INJ_W%d',i);
disp('** UBA wi Status Connection');
disp('1 2 1 0.001 OPEN FLOW-FROM SURFACE')
disp('**')
end
You can modify it as per your requirements, just used all simple functions.
3 Comments
Bjorn Gustavsson
on 7 Feb 2019
Well, the just think a couple of minutes about what the fprintf-lines and the disp-lines do, what separates them and how to possibly modify the suggested solution. This is not a site where you necessarily get your job done - you'll have to settle for suggestions for how to do your job, how to solve problems in doing your job and might even give you helpful hints and tricks to get your job done...
HTH
More Answers (1)
Bjorn Gustavsson
on 7 Feb 2019
for i_n = 1:200
fprintf('text-for-row %d\n',i_n)
fprintf('text-for-next-%02d-row\n',i_n)
end
HTH
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!