Summation Evaluation for loops shifting purposes
1 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Walter Roberson
2014-2-13
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 个评论
Walter Roberson
2014-2-13
I am getting confused because the variable names you are using in your code do not match what is in the diagram.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!