How to convert phyton script to matlab script

3 Ansichten (letzte 30 Tage)
mohd akmal masud
mohd akmal masud am 23 Jul. 2023
Kommentiert: Pratyush am 26 Jul. 2023
Dear All,
I have phyton script as attached.
Anyone can help me to convert it into matlab script? Or it can call in matlab else..
Please help me.

Akzeptierte Antwort

Pratyush
Pratyush am 26 Jul. 2023
Bearbeitet: Pratyush am 26 Jul. 2023
Hi Akmal,
I understand that you want a way to call your python scripts from MATLAB. This could be done using the "system" function.
Let say you have a script "test.py". To call it from MATLAB run the following code:
% Path to the Python script
pythonScript = 'test.py';
% Command to execute the Python script
command = ['python ', pythonScript];
% Call the Python script from MATLAB
system(command);
You can refer to the following documentation to call your python scripts from MATLAB: Call Python from MATLAB - MATLAB & Simulink - MathWorks India
  4 Kommentare
mohd akmal masud
mohd akmal masud am 26 Jul. 2023
Bearbeitet: mohd akmal masud am 26 Jul. 2023
Dear @Pratyush,
I was add, then suceesful.
But, the new error appear
>> % Path to the Python script
pythonScript = 'ProposedNetwork.py';
% Command to execute the Python script
command = ['python ', pythonScript];
% Call the Python script from MATLAB
system(command);
Traceback (most recent call last):
File "C:\Users\Akmal\Downloads\ProposedNetwork.py", line 1, in <module>
import torch.nn.init as init
ModuleNotFoundError: No module named 'torch'
How to download the module torch?
Dear @Pratyush, as attached is my phython script.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by