What is the matlab code syntax to create a temporary array in MATLAB ?

6 次查看(过去 30 天)
I am working on the fault detection and fault classification in power system using wavelet and ANN in matlab/simulink. I need to sense the fault current from the power system model drawn in simulink, and the waveform of the fault current displayed in the scope will be converted into data and has to be stored temporarily in the form of array in workspace (as a memory) and this data samples stored in the array shall be fed to wavelet code (along with 0.05 sec time step, so that window can be made) and the wavelet code can calculate the fault coefficients and these fault coefficients can be fed to the ANN controller to detect the correct type of fault. Once the data samples is fed to the wavelet code after 0.05 sec, that data samples stored in array will be cleared and new data samples will be stored in the form of array in workspace. Again this data samples is fed to wavelet code and wavelet code will calculate the fault coefficients and after next 0.05 sec the data samples stored in the array will be cleared and new data samples will be stored in the array in workspace. In this way at every 0.05 sec time step, the data samples will be stored in the array and will be given to wavelet code and the array will be cleared and new data samples will be stored in the array. This array is called "temporary array".
The question is that how to create this temporary array in MATLAB ? What is the matlab code syntax for creating this temporary array ? I just want only suggestion. I am not asking for an exact answer.
  1 个评论
dpb
dpb 2022-6-9
tmp=zeros(N,1);
creates a column vector of N elements you can write into...it will have to be in scope of whatever it is that is doing the calculation or be global.

请先登录,再进行评论。

回答(1 个)

Ganesh Gudipati
Ganesh Gudipati 2022-6-13
Hi Siddharth,
As per my understanding you want to create an array and at each timestep the new samples should replace the old samples.
Create a array of initial size ‘n’ using the command
tempArray = zeros(1,n);
% no of rows =1, now of columns = n;
Let us consider your model as a function. Now this function takes the tempArray and it will modify the array at each time step.
Once this whole execution is done, and the tempArray is no more required
clear(tempArray)
%This removes the array from the workspace and frees the memory.
For more information refer Matrices and Arrays

类别

Help CenterFile Exchange 中查找有关 Signal Generation, Manipulation, and Analysis 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by