How to build a system of iteration for multiple interrelated variables?

3 views (last 30 days)
Primarily, I have 5 variables - q1,q2,q3,q4 and ts. q1,q2,q3,q4 are dependent on ts and ts is also dependent on q1,q2,q3,q4. I have the initial values of all of these q1,q2,q3,q4 and ts. Then comes t2 which I get from the above 5 variables. and Then ts(new) = ts+t2. For this new ts, the values of q1,q2,q3 and q4 again change and we get new t2, and ts is changed again....the process should go on.
How do I develop this system in Matlab? I am new in matlab, but not very novice.
  4 Comments
jgg
jgg on 24 Feb 2016
Sorry, this should be V = zeros(maxiter,5); instead of 6; I miscounted your variables.
Mahbubur Rahman
Mahbubur Rahman on 27 Feb 2016
Thanks a lot, jgg. I followed your coding first and eventually was able to solve it using my own ideas.
But I am looking for a new suggestion now. If you look at this code - the number of iteration n is the iteration counter but for me it is also the seconds of the system (with max time 8 sec). I need the n (or sec which can be fractional) for which ts = 1000 inside the loop.
a = 5;
b = 22;
c = 13;
d = 4;
ts = 50+ 4*b;
stamp = zeros(1,8);
for n = 1:8
ta = 1+(b+a)/n*c;
ts = ta +ts;
b = b+1;
a = a + b/2;
c = c-.5;
stamp(n) = ts;
end
disp(d)
disp(a)

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!