Prepare dataset for Neural State Space to be used as StateFcn in nlmpc
10 views (last 30 days)
Show older comments
Saskia Putri
on 23 Nov 2023
Commented: Saskia Putri
on 4 Dec 2023
Hello,
I am trying to use the neural networks using the Neural State Space Models in MATLAB to be used as a state function in nonlinear mpc toolbox. During the training and validation process I want to use normalize data of the dataset to yield a generalizable data. However, I am not sure how to denormalize the data once the training and validation have been conducted. Can anyone one help me with this?
Thank you in advance.
3 Comments
Accepted Answer
Arkadiy Turevskiy
on 27 Nov 2023
Thanks for posting the code.
To de-normalize the data you need to save mean and standard deviation data used for normalization.
[TdataN,C,S]=normalize(Tdata);
% now train neural state space, use it to predict normalized data PdataN
% using sim
% Now you can "de-normalize"
Pdata=PdataN.*S+C;
HTH
Arkadiy
5 Comments
Arkadiy Turevskiy
on 30 Nov 2023
Hi,
In your case it looks like the outputs (same as states) are the last 9 columns of TTdata, right?
So the bias and standard deviation info you need are in the last 9 columns of C and S in my code snippet in the answer.
Take those and use to denormalize your state derivatives/states/outputs as needed.
[TTdataN,C,S]=normalize(TTdata);
% your code to train neural state space model goes here
% you compute state derivatives dxdt1 as in your code above
% Now you can "de-normalize" state derivaties
% The code below assumes TTdata has 12 columns, the first 3 columns are
% inputs, and the last 9 are states/outputs
Cstate=C(4:length(C));
Sstate=S(4:length(S));
dxdt1_denormalized=dxdt1.*Sstate+Cstate;
Hth
More Answers (0)
See Also
Categories
Find more on Linear Plant Specification in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!