Info

This question is closed. Reopen it to edit or answer.

Trying to do a lot of compares within a bunch of arrays

1 view (last 30 days)
I have the following arrays (in simplest form, that will be larger once I get the basics down):
one for current time, CurrentTime = [0;0;0]
one for Machine # by part, Machine = [2;1;2]
And one for time on the machine, MachineTime = [5;10;15]
Step 1: I want to first find the min value of Current Time
Step 2: If there are 2 or more min values
Step 3: find if the values in the the same position of Machine are the same values (in this case, pos 1 and 3 are the same)
Step 4:If True, find out the min of the values in the same position of MachineTime
So the following results should be seen for provided data:
Result of Step 1 should be a vector =
find(CurrentTime = min(CurrentTime)) = [1;2;3]
Result of Step 2 should be value = numel(vector) = 3
Result of Step 3 = vector2 = [1;3]
Result of Step 4 = value2 = 1
Then I can move forward that the time for part 1 uses machine 2 for 5 minutes, before part 3 uses machine 2 for 15 minutes.
Any help would be appreciated, very stuck on this.
The intent of this problem is to have an array of the current time of each part, an array for the order of machines needed to create each part and an array of the time each machine takes per part.
The current time array can have any value, in this case, we are at the start of the project, and every part hasn't been started, so they all have a current time of zero.
I want to add the part with the lowest current time to the machine it is expected to use first, but this case, they all have the same current time, so I need to check if more than 1 part is going to be on the same machine at the same time, so from the Machine array, part 1 and part 3 are supposed to be on machine 2 at time 0.
Since there are 2 parts supposed to be on the same machine, I have to use a dispatch rule to determine which one gets on machine 2 first. The dispatch rule I'm using, is the one that takes the least amount of time on the machine, in this case, part 1 only takes 5 minutes, where as part 3 takes 15 minutes.
Once I get to the point where the code knows that part 1 should take 5 minutes on machine 2 before part 3 gets on machine 2, I want to add 5 to the current time of part 1.
Then since machine 2 was busy while part 1 was on it, the current time of part 3 will be 5 minutes plus the time it took for part 3 on machine 2 for a total current time for part 3 of 20 minutes.
Hopefully this intent helps for a better understanding of my problem.
  2 Comments
Andrew Newell
Andrew Newell on 12 Mar 2015
Edited: Andrew Newell on 12 Mar 2015
A note on markup: If you want material to appear on a new line, you have to put a blank line in between.
dpb
dpb on 12 Mar 2015
On markup, this is true for text but the better way is to treat it as Code sections (highlight and use the button or insert two blanks at beginning of first line of section). Or, in the OP's case, using the number list for the steps would work well.
Pet Peeve Aside: Why, oh why can't TMW fix it so word wrap is "off" and stuff will look like put in and pasted code will automagically be ok???

Answers (1)

dpb
dpb on 12 Mar 2015
Doesn't seem as though Step 2 really has any bearing (need for an "if"); the result is the same either way???
But, for Step 3 look at
doc unique % note the optional return values as well
On Step 4, there seems to be an anomaly in that the suggested result isn't at the locations that are duplicates but the minimum in the middle.
I think you need to work on the precision of the problem description including these boundary/end conditions this example illustrates where the first vector is degenerate as to how the rules are really formulated.
Perhaps a verbal explanation of the intent would also help.
  1 Comment
ootervon
ootervon on 12 Mar 2015
Hopefully added a verbal explanation to the end of the questions that shows my intent better.

Community Treasure Hunt

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

Start Hunting!