fprintf statement with multiple looping variables.
5 views (last 30 days)
Show older comments
Hi, I need to print out a statement that has multiple looping variables with different iterations. I am pretty sure I cannot use the "for" loop statement here, but i'm unsure what else I can do. I need to print (probably using fprintf) iterations of something like this:
ELSE IF (TIME(1) <= 3.419999e+00 ) THEN
FLUX(1)=AMG*EXP(-2*(((COORDS(3)+V*TIME(1)- 6.498 )**2+(COORDS(1)- 0.2484 )**2)/(R**2)) FLUX(2)=0.0
The numbers in bold are my 3 variables. The first number (3.419999e+10) increases by a value of 0.001579 per increment, the second number (6.498) increases by 0.0012 per increment and the third increases by 0.0009 per increment. The next statement should read:
ELSE IF (TIME(1) <= 3.421578e+00 ) THEN
FLUX(1)=AMG*EXP(-2*(((COORDS(3)+V*TIME(1)- 6.4992 )**2+(COORDS(1)- 0.2493 )**2)/(R**2)) FLUX(2)=0.0
Can anyone show me how to create 3 different variables, with different iterations per loop step? Thank you!!!
0 Comments
Answers (2)
TS
on 25 May 2014
if i understand your question correctly, you can use a for loop. a simple example:
a = 3.419999e+00;
b = 6.498;
c = 0.2484;
a_inc = 0.001579;
b_inc = 0.0012;
c_inc = 0.0009;
for i=0:10
a_current = a+i*a_inc;
b_current = b+i*b_inc;
c_current = c+i*c_inc;
disp(['(a,b,c) = ' num2str([a_current b_current c_current])])
end
there are also many other ways to do this..
0 Comments
See Also
Categories
Find more on Logical 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!