Using CoolProp in MATLAB

39 views (last 30 days)
Eray Demirhan
Eray Demirhan on 18 Aug 2023
Edited: hsin-yu on 16 Feb 2024
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.

Answers (2)

Sai Teja G
Sai Teja G on 28 Aug 2023
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 on 16 Feb 2024
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 Comment
hsin-yu
hsin-yu on 16 Feb 2024
Edited: hsin-yu on 16 Feb 2024
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.
--------------------------------------------------------------------------

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!