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

1 次查看(过去 30 天)
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 个评论
jgg
jgg 2016-2-24
Sorry, this should be V = zeros(maxiter,5); instead of 6; I miscounted your variables.
Mahbubur Rahman
Mahbubur Rahman 2016-2-27
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)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by