NN predictive controller - Internal S-function 'predopt', flag = 2 (update) problem
Show older comments
Hi there,
I'm encountering this problem for the first time, also i'm new to MATLAB & SIMULINK so please any help will be appreciated.
I'm trying to use NN to control the acceleration of a 1/2 car model, so that i used "NN predictive controller" block as shown and identified the NN plant. But when I run the si,ulation it gives this error:
- Error in 'untitled/NN Predictive Controller/S-Function' while executing MATLAB S-function 'predopt', flag = 2 (update), at time 0.0."
- Subscript indices must either be real positive integers or logicals.
Whatever i tried it just wouldn't work and I'm not understanding what should I do?


3 Comments
Carolina Borges
on 11 Feb 2019
I am facing the same problem. I've already tried re-train the network, changed controlled parameters but nothing is working.
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Error in 'testeagain/NN Predictive Controller/S-Function' while executing MATLAB S-function 'predopt', flag = 2 (update), at time 0.0.
- Array indices must be positive integers or logical values.
Yash Raghuwanshi
on 29 May 2021
change delay to 2
Ahmed EL-Ebiary
on 3 Jul 2021
which delay please as i face the same problem
Answers (1)
Jake Rankin
on 21 Feb 2019
0 votes
I fixed my error after going back over some documentation
And the variable that altered it for me was No. Delayed Plant Input. Mine never worked if it was 1 so I changed it to 2.
I also used the training function trainbr when training my parameters.
Sorry it's not a technical answer, but that's what helped me :)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!