1

In my undergrad thesis I am creating a neural network to control automated shifting algorithm for a vehicle.

I have created the nn from scratch starting from .m script which works correctly. I tested it to recognize some shapes.

A brief background information;

NN rewires neurons which are mathematical blocks located in a layer. There are multiple layers. output of a layer is input of preceding layer. Actual output is subtracted from known output and error is obtained by this manner. By using back propagation algorithm which are some algebraic equation the coefficient of neurons are updated.

What I want to do is;

in code there are 6 input matrices, don't have to be matrix just anything and corresponding outputs. lets call them as x(i) matrices and y(i) vectors. In for loop I go through each matrix and vector to teach the network. Finally by using last known updated coeffs networks give some responses according to unknown input.

I couldn't find the way that, how to simulate that for loop in simulink to go through each different input and output pairs. When the network is done with one pair it should change the input and compare with corresponding output then update the coefficient matrices.

I model the layers as given and just fed with one input but I need multiple. enter image description here When it comes to automatic transmission control issue it should do all this real time. It should continuously read the output and updates the coeffs and gives the decision.

freezer
  • 531
  • 1
  • 11
  • 28
  • Is there a specific reason not to use the recommended work flow? That would be training in matlab, then generate a simulink block for the neuronal network. – Daniel Jan 03 '16 at 08:28
  • What did you mean saying the recomended workflow? – freezer Jan 04 '16 at 20:29
  • Hello, @freezer. Have you resolved your issue? I'm facing a kind of similar one: https://stackoverflow.com/questions/64534207/what-is-the-best-way-to-build-a-model-of-automated-system-with-neural-network-in May be you have an answer? – Victoria Oct 26 '20 at 10:32

1 Answers1

2

Check out the "For each Subsystem". Exists since 2011b

To create the input signals you use the "Concatenate" Block which would have six inputs in your case, and a three dimensional output x.dim = [1x20x6] then you could iterate over the third dimension...

A very useful pattern to create smaller models that run faster and to keep your code DRY (Dont repeat yourself)

renzop
  • 1,194
  • 2
  • 12
  • 26
  • I used "For Subsystem" and "Multiport Switch" but doc says that for block runs all the iterations in a single timestep. I need to know and plot those calculated outputs and error to see the decrease. It is great to run it fast indeed. But it prevents me to analyze the process. – freezer Jan 04 '16 at 20:12
  • Just the make the signals of interest on an out port of the for each subsystem. Then you can analyse them like any other signal outside the for each subsystem. Your question would be easyer to understand if you separate the Domain specific Neruonal part from the Simulink implemetation question. – renzop Jan 06 '16 at 08:21
  • do you hardly recomend me to use foreach instead of for subsystem. The other thnik which I have concerns, how simulink solves all the iteration inside for subsystem in the current timestep. What if process time exceeds the timestep? – freezer Jan 07 '16 at 21:56
  • Yes I recommend to use the for each subsystem... I also looked a the generated c code, and in general it offers more possibilities (you can iterate over an array of buses etc.... but you can not access the iterator (index)).. According to your process time question... Simulink will calculate the stuff until its done... If you have a realtime application... Its another topic... not to handle in this question. – renzop Jan 15 '16 at 14:52