필터 지우기
필터 지우기

Using CoolProp in MATLAB

조회 수: 33 (최근 30일)
Eray Demirhan
Eray Demirhan 2023년 8월 18일
편집: hsin-yu 2024년 2월 16일
Hi guys, I am currently using MATLAB 2023a and I have added CoolProp to MATLAB. But now I am trying to make a standalone app so others with no MATLAB on their computer can use it. But when I share my app their computer doesn't recognise CoolProp formulas. Is there any way I can make this work ? Thank you.

답변 (2개)

Sai Teja G
Sai Teja G 2023년 8월 28일
Hi Eray,
I understand that you want to run your app in other computers where MATLAB is not installed.
It is indeed possible, and you can achieve it by following the link provided below to ensure its functionality.
Hope it helps!

hsin-yu
hsin-yu 2024년 2월 16일
I also encountered the same problem. I compiled the thermal property calculation APP on a computer with MATLAB, and packaged the APP and sent it to a user who did not have MATLAB. The user had python installed, but the python environment status was detected as not loaded. Therefore it cannot be calculated.
Is this because the APP cannot execute the command window ?
If the APP has this limitation, how to solve it?
------------------<my code>---------------------------------------------------------------
% Prompt the user for the Python installation directory and provide examples
default_python_dir = 'C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe';
python_dir_cell = inputdlg('Please enter the directory where Python executable is located:', 'Python Directory', [1, 100], {default_python_dir});
python_dir = char(python_dir_cell);
% If the user cancels input, return
if isempty(python_dir)
return;
end
try
% Try to execute pyenv
pe = pyenv("Version", python_dir);
% Display Python environment information
disp(pe);
% Convert Python environment information to a string
pe_str = evalc('disp(pe)');
% Display Python environment information string
msgbox(pe_str, 'Python Environment');
% Determine whether to import CoolProp based on whether Python status is loaded
if strcmp(pe.Status, 'Loaded')
% Try to install CoolProp
[v, e] = pyversion;
cmd = [e, ' -m pip install --user -U CoolProp'];
system(cmd);
pause(0.1);
% Display success message box
msgbox('Connected successfully.', 'Success');
else
% Show error message box
msgbox('Python is not loaded. Please make sure Python version supports MATLAB.', 'Error');
end
catch ME
% If an error occurs, display an error message box
errorMessage = ME.message;
msgbox(errorMessage, 'Error', 'error');
end
  댓글 수: 1
hsin-yu
hsin-yu 2024년 2월 16일
편집: hsin-yu 2024년 2월 16일
Success! Use Windows CMD to execute the coolprop connection command!
--------------------------------------------------------------------------
cmd_path = 'C:\WINDOWS\system32\cmd.exe';
command = ['"', cmd_path, '" /c "', python_dir, '" -m pip install CoolProp'];
% python_dir is your python.exe path.
--------------------------------------------------------------------------

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by