Info

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

Matlab code generation. Iterate cycle on a vector.

1 view (last 30 days)
luca
luca on 8 Jul 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi to everybody,
I have a given vector with the following value V = [ 3 1 3 1 2 1 3] and the task is to write a code that is able to do this:
1 2 and 3, in the vector V, represent the entities that a machine can work. The machine can work 2 different entities without making a set up change, when a third different entity is entering the system, we have to change the configuration of the machine (set up time is needed). The vector V describe the entites that are entering in the machine. The situation is this:
1) The first entity that enter is 3 (as can be seen in V). The machine is empty. So the first value of a new vector X should be 0. (0=no set up)
2) The second entity is 1. The machine can work up to two different entities withouth making a set up. So we have another free space. So the second value of the new vector X should be 0. (0=no set up)
3) The third entity is 3. Due to the fact that 3 was already machined before, no set up change is needed. So the third value of the new vector X should be 0. (0=no set up)
4) The fourth entity is 1. Again 1 have been already machined. So the fourth value of the new vector X should be 0. (0=no set up)
5) NOW 2 is entering the machine. Till now 3 and 1 have been worked, so in this case we need a set up change.What happen in the real case is that the older entity (3) will be removed to free up space for the new one (2). If we take a look at the system we see that 1 is the last entity that entered the system, while type 3 came in before 1 ( chronological order) This mean that machine configuration for type 3 will be removed and 2 will enter the system with a set up change. So the fifth value of the new vector X should be 1. (1= set up is needed).
6) the seventh entity will be 1. 1 is present in the previous two different entities. So the seventh value of the new vector X should be 0. (0=no set up)
7) NOW entity 3 is entering the system. The previous two entity were 2 and then 1. it means that 2 will be removed to free a space for 3. So the eighth value of the new vector X should be 1. (1= set up is needed)
May someone help me with the code? The final should be to obtain the Final Vector X with value 0 or 1, that states if the set up is needed or not.

Answers (0)

This question is closed.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!