addition of image files during compiling to make a standalone app

5 visualizaciones (últimos 30 días)
I have created an app design in MATLAB. This app shows the images in the right tab for choosen type in the left tab. Images are stored in the current folder. while running app in MATLAB, app is running smoothly without any error and also showing images as per requirement. then I used share option to make a standalone app. in the MATLAB compiler section, I have uploaded all the necessary files including images and clicked on packages. It made the app in a specific project folder. but after running the application from the folder named 'for_testing', images are not showing but the other things are working smoothly.
even after adding the image files in the the files required in the application to run, why the image is not showing in standalone app.

Respuesta aceptada

Image Analyst
Image Analyst el 11 de Ag. de 2025
Did you use the deploytool or the mcc command? If you used the mcc command, did you use the -a option to attach your files. I always use the mcc command and usually don't include files. I use the Centurion Setup program to bundle my executable and all my other files that are needed into an installation package. Th Centurion Setup program is by far the best, easiest, and most intuitive of the installation package building programs available. That way I know what files are getting shipped and where they will live. With the compiler, it's a mystery. Anyway, see the FAQ:
and
and it may give you some clues about the mystery of where files get extracted and stored when you deploy a MATLAB executable. It's a long, complicated story that I can't elaborate on now.
  6 comentarios
SUMAN
SUMAN el 18 de Ag. de 2025
please see my code for image ploting
function PlotDisplaySwitchValueChanged(app, event)
value = app.PlotDisplaySwitch.Value;
if strcmp(value, 'On')
[sg_label, sg_full_label] = app.getSubgradeSuffix();
[load_label, load_full_label] = app.getLoadTypeLabel();
% Compose image filenames
img_1 = ['stress_blst_' sg_label '_' load_label '.png'];
img_2 = ['stress_sbg_' sg_label '_' load_label '.png'];
img_3 = ['settlement_blnkt_' sg_label '_' load_label '.png'];
img_4 = ['settlement_sbg_' sg_label '_' load_label '.png'];
% Use correct path for standalone (deployed) app
if isdeployed
img1 = fullfile(ctfroot, img_1);
img2 = fullfile(ctfroot, img_2);
img3 = fullfile(ctfroot, img_3);
img4 = fullfile(ctfroot, img_4);
end
imgPath1 = fullfile(pwd, 'NEWAPP',img_1); % Assuming images are in a folder named 'images'
imgPath2 = fullfile(pwd, 'NEWAPP',img_2); % Assuming images are in a folder named 'images'
imgPath3 = fullfile(pwd, 'NEWAPP',img_3); % Assuming images are in a folder named 'images'
imgPath4 = fullfile(pwd, 'NEWAPP',img_4); % Assuming images are in a folder named 'images'
try
img1 = imread(imgPath1);
img2 = imread(imgPath2);
img3 = imread(imgPath3);
img4 = imread(imgPath4);
% Display image in your app
catch ME
disp(['Error loading image: ', ME.message]);
end
% Set Stress Tab active and update images
app.TabGroup2.SelectedTab = app.PLOT1Tab;
if isfile(img_1)
app.StressBelowBallastImage.ImageSource = img_1;
else
app.StressBelowBallastImage.ImageSource = '';
end
app.TabGroup2.SelectedTab = app.PLOT2Tab;
if isfile(img_2)
app.StressBelowSubgradeImage.ImageSource = img_2;
else
app.StressBelowSubgradeImage.ImageSource = '';
end
% Set Settlement Tab active and update images
app.TabGroup2.SelectedTab = app.PLOT3Tab;
if isfile(img_3)
app.SettlementTopBlanketImage.ImageSource = img_3;
else
app.SettlementTopBlanketImage.ImageSource = '';
end
app.TabGroup2.SelectedTab = app.PLOT4Tab;
if isfile(img_4)
app.SettlementTopSubgradeImage.ImageSource = img_4;
else
app.SettlementTopSubgradeImage.ImageSource = '';
end
end
end
even after applying your instructions, it is runnning in the same computer but not in other computer. As it prompts unable to find the image file.
mcc -m UIC_RDSO_PROJECT.mlapp -a 'blnkt_settlement_17T.mat' -a 'blnkt_settlement_25T.mat' -a 'blnkt_settlement_32_5T.mat' -a 'images';
Image Analyst
Image Analyst el 18 de Ag. de 2025
I still see semicolons. Did you not see my instruction where you leave off the semicolon so that you can see the actual filename in the console window? Then you can see if it's really the location you expect. And use fullfile with img_1. And why do you assign img1 (no underline) in the "if deployed" only to immediately reassign it after the try? And it can lead to confusion if you have both img1 and img_1, similar filenames even though neither one is really an image variable (they're strings!).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Standalone Applications en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by