Summation Evaluation for loops shifting purposes

1 view (last 30 days)
Sam
Sam on 13 Feb 2014
Edited: Sam on 13 Feb 2014
For the following Summation i am able to evaluate it by hand but the coding in matlab wise i am a little confused as the value of t changes with each iteration i am not able to write i as a normal for loop.
I have a 24x14 Matrix containing X-Data and a 1x14 Matrix containing D-Data
- X represents number of devices and D represents its current usage
- t=24; L=14; (Mathematically t is only true for 3:24 since i need to measure a shift)
Whats happening here is that i am measuring the shift in this 2-Dimensional Matrix from time i till time t. Since the value of t is varying from 3 till 24 i cannot write this as a normal for loop, as normal for loops will only count from i=1 till i=t but here my t value is also climbing with each iteration. now how could i approach this in matlab?
Basically X number of devices of type j that are shifted from time i to t.
My attempt is as follows... I believe it is still erroneous and needs a little work
for t=3:1:time-1 % time = 24
for L=1:1:14
value(t,L) = x_data(1,k) - x_data(t,L);
value(t,L) = cD1(t,L) * d(1,L);
end
end
Many thanks for any advice you could provide me with!

Answers (1)

Walter Roberson
Walter Roberson on 13 Feb 2014
Using
for l=1:1:t
would be fine. The limits of the inner "for" get re-evaluated each time the "for" is reached by the flow of control from above.
  2 Comments
Sam
Sam on 13 Feb 2014
Edited: Sam on 13 Feb 2014
Hi Walter.. Thanks. could you help to clarify a little please.. you are talking about the outer for right? also, i need L to only count from 1 till 14 but if i set L to count from 1 till t, it will then count from 1 till 24.
Walter Roberson
Walter Roberson on 13 Feb 2014
I am getting confused because the variable names you are using in your code do not match what is in the diagram.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!