Automatically Run a Matlab Script

15 ビュー (過去 30 日間)
fahd Belmajdoub
fahd Belmajdoub 2020 年 3 月 3 日
編集済み: fahd Belmajdoub 2020 年 3 月 5 日
I have a script that I want to run automatically, every 5 seconds. How could I set this up so that it runs in an unattended manner?

回答 (1 件)

the cyclist
the cyclist 2020 年 3 月 3 日
  9 件のコメント
Steven Lord
Steven Lord 2020 年 3 月 5 日
Do you need to run the script from the beginning every five seconds, or would running a script that loops indefinitely and polls for data to process every five seconds be sufficient?
fahd Belmajdoub
fahd Belmajdoub 2020 年 3 月 5 日
編集済み: fahd Belmajdoub 2020 年 3 月 5 日
The script actually consists on importing variables from an OPC server coming from a PLC, make a prediction for a new variable using neural networks, then write this new predicted variable to the OPC server (see code below). So, I think the script should be running systematically in order to retrieve new data from the input variables, and write the new predicted value of the output to OPC server.
%% OPC connection
da= opcda('Localhost', 'Matrikon.OPC.SiemensPLC.1');
connect(da);
%create Group
grp = addgroup(da, 'YYY');
%Add Tags
additem(grp, {'TCP CHANNEL>YYY>FeedRate', 'TCP CHANNEL>YYY>Reject', 'TCP CHANNEL>YYY>puissanceelevderecirc', 'TCP CHANNEL>YYY>Clinker','TCP CHANNEL>YYY>Limestone', 'TCP CHANNEL>YYY>RegistreRecirculation' , 'TCP CHANNEL>YYY>Maindrivepower', 'TCP CHANNEL>YYY>Temperaturesortiebroy', 'TCP CHANNEL>YYY>Puissanceseparateur', 'TCP CHANNEL>YYY>pressionsortiebroyeur', 'TCP CHANNEL>YYY>Electronicear', 'TCP CHANNEL>YYY>Gypsum'});
%Retrieve Data
r = read(grp);
%r(:,1).Value
X = extractfield(r,'Value').';
%Clean up
disconnect(da)
delete(da)
%% Predict output
Y = MatlabMatrixonlyfunction(X)
%% OPC Write
da = opcda('Localhost', 'Matrikon.OPC.SiemensPLC.1');
connect(da);
grp = addgroup(da, 'DemoGroup');
itmIDs = {'TCP CHANNEL>YYY>FinesseLaboratoire'};
itm = additem(grp, itmIDs);
% read and write values to and from the items
write(itm, Y);
R45predite = read(itm);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by