How do I convert a "py.int" into a string?

10 Ansichten (letzte 30 Tage)
Jan Bartels
Jan Bartels am 18 Jun. 2022
Beantwortet: Walter Roberson am 19 Jun. 2022
Hello,
I have a python file that I am executing via pyrunfile that returns a number, the number is stored in Matlab as a py.int.
I need to turn this number into a string to append to an output, but neither str(py.int), string(py.int), num2str(py.int), or int2str(py.int) work.
Here is the approximate setup:
app.program_PID = pyrunfile("StartProgram.py", "PID");
class(app.program_PID) % py.int
disp(app.program_PID) % Python with int properties:
% denominator: [1x1 py.int]
% imag: [1x1 py.int]
% numerator: [1x1 py.int]
% real: [1x1 py.int]
% 99999
%Later
pyrunfile("StopProgram.py " + num2str( app.PhaseSpace_PID ) ); % This does not work "Input num2str must be numeric"

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Jun. 2022

Weitere Antworten (0)

Kategorien

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

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by