How can ı create windows for LSTM in simulink

31 次查看(过去 30 天)
Dear sir,
I am working on fault detection and fault classification for three phase inverter.
I trained a LSTM with 37755x1 cell XTrain and 37755x1 categorical TTrain datasets.
Each one cell is 200x6 double dataset in XTrain as a seen in pictures. (3 Phase voltage and 3 phase current)
TTrain is categorical label as a seen pictures. (Fault station)
LSTM has an input length of 200 samples.
I have to create the window in simulink that can take 200 samples from voltage and current sensors and it will feed to the LSTM.
Again in the next sequence, the window take 200 samples from sensors and it will feed to the LSTM
How can I create a window in Simulink that can hold 200 sample data points which read from voltage and current sensors?
My simulation solver time=1e-6 sec
Voltage and current sampling time= 5e-05 sec

采纳的回答

Nithin
Nithin 2025-8-18,9:19
To create a window in Simulink that holds 200 samples of your six-channel signal (3-phase voltage and 3-phase current) and feeds it to your LSTM, use a buffering mechanism that accumulates incoming data into overlapping or non-overlapping windows of the required size. Since the LSTM network expects an input of size "200×6", you must buffer the real-time sensor data into chunks of 200 samples for each channel before passing it to the "LSTM block".
In Simulink, this is accomplished using the "Buffer block". The "Buffer block" allows you to specify the window length (200 samples) and the frame-based processing, so it collects 200 consecutive samples before outputting them as a single matrix. Since the simulation has a solver step of 1e-6 seconds, but the sampling time for each measurement is 5e-5 seconds, you need to ensure that the data is sampled and buffered at the correct intervals.
Use a "Rate Transition block" or set the sample time of the "Buffer block" to match the data acquisition rate (5e-5 seconds).
Once the "Buffer block" collects 200 samples, it outputs a 200x6 matrix at each step, which matches the input format your LSTM network was trained on. This matrix can then be fed directly into the LSTM block for classification or fault detection.
Refer to the snapshot of the sample model below:
Refer to the following MathWorks documentations for more information:
  1 个评论
Bahadir
Bahadir 2025-8-20,11:14
编辑:Bahadir 2025-8-20,16:02
Dear @Nithin
Thanks you very much for your answer.
The problem is dimension for your answer. LSTM need 200x6 input cell data.
But the buffer give 200x1 array.
I checked sample time and sample data. The sample interval and value of sampled data is correct.
When I analyze the buffer output data, the first 200 data are arranged in order from 1 to 200, the second 200 data are arranged from 201 to 400, and the third 200 data are arranged from 401 to 600.......
When I change the position of Transpose, the simulation works fine. I placed Transpose between Rate Transition and Buffer. Everything is OK.
Thank you.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by