Dynamic Variable with Two Values Inside a While Loop
2 ビュー (過去 30 日間)
古いコメントを表示
How to express a dynamic variable with two values or more inside a while loop:
An example of what I mean by a dynamic is a time of a job in a work shop at one of the machines so (Tij) T is for Time i is the job identification number, where i=(1,2,3) as an example j is the machine identification number, where j=(1,2,3,4,5,6) as an example
So when I say: T35 is the time of the 3rd job in the 5th machine. T11 is the time of the 1st job in the 1st machine. T35 & T11 can occur at the same time, let say both occurred when time = 1:00pm
My question how create a while loop that will finish all the three (3) jobs in all the six (6) machines. Also let say each machine takes 3 minutes to complete a job and it can only treat one job at a time.
I not sure if this dynamic variable can be an array or a structure or something else.
1 件のコメント
回答 (1 件)
dpb
2017 年 1 月 15 日
Don't see that you need any loop at all. Simply populate a nJobMax by nMachines array with the appropriate start time values and accumulate total duration by column given the job duration as being fixed.
If the assignment is N jobs to the machine at one time to be processed sequentially, then it's even more trivial of just being that number*duration/job plus the starting time.
The new datetime class with duration variables should make this pretty simple to code.
6 件のコメント
dpb
2017 年 2 月 23 日
Well, there are any number of examples of for loops, but the power in Matlab is in the vector operations. You'll probably want an outer loop for each of the trials, but look again at the solution above without looping that solves the time issue for all machines and all times for a given sampled duration dataset without needing any loops at all.
And, forget you've even heard of eval, there "there be dragons!" :)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!