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

3 vues (au cours des 30 derniers jours)
Mahbubur Rahman
Mahbubur Rahman le 24 Fév 2016
Commenté : Mahbubur Rahman le 27 Fév 2016
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 commentaires
jgg
jgg le 24 Fév 2016
Sorry, this should be V = zeros(maxiter,5); instead of 6; I miscounted your variables.
Mahbubur Rahman
Mahbubur Rahman le 27 Fév 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)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by