I have modeled a basic mass-spring-damper system in simulink, with 2 different input options, step and a chirp block for finding freqeuncey reponse.
I have followed the steps listed in the video tutorial for the Reduced Order Modeling add on "AI with Model-Based Design: Reduced Order Modeling." So far, I have been able to follow all the way up until the LSTM model has been trained (selecting the one with the lowest values for training and test loss.) At this point, the video says to save the training output, in which it then pops up in the matlab workspace. (I have it saved as trainingOutput_062325.) I also tried saving the output file (as lstm_model_062325) to my desktop and retreiving it from there.
I am now wanting to use this trained LSTM model in my simulink file, and compare it's output with the output from running the actual system. However, I am having difficulty with this. I was planning on using a Stateful Predict block and using the network as an input, but no matter how I save the files, it seems to give errors. I first tried to save the entire outputfie as a .mat file and use this in the statful prediction but that did not work. Here is my current attemp to save the dlnetwork found within the output file.
loadedModel = load('lstm_model_062325.mat');
lstmNet = loadedModel.trainingOutput_062325.Network;
save('lstm_model_062325.mat', 'lstmNet');
myDlnet = lstmNet;
save('my_dlnetwork.mat', 'myDlnet');
I am able to see that the file my_dlnetwork.mat is not empty and I can see that myDInet is a 1x1 dlnetwork variable in the matlab workspace, however, I get this error no matter how I try to implement it in the staful predect block.
"Error using second_order_script
Error in 'second_order/Stateful Predict': Failed to evaluate mask initialization commands.
Caused by:
Error using second_order_script
Network input data format string cannot be empty"
Once the LSTM model output is saved, what is the simplest way to use the model? The video turorial uses preloaded files and does not explain the method. Any help is appreciated, thanks.