MATLAB: Stand alone “.exe” file not saving images

save image

Hi,
I'm trying to create an ".exe" file that will read some sort of data(for a known path), and will plot it one time as "bplot" and the other time as "histogram".
The code works fine as I run it from the editor, and even after I've made an ".exe" file. The problem begins when I try to run it from a "C#" code with the command "Process.Start(@"path\.exe")". It seems like it runs the code and I can see the figures that are made, but it doesn't save the picutres.
My matlab code is:
clear
clc
P = csvread('my_path\test_csv.csv');
SP = bplot(P);
pause (3);
saveas(figure(1),[pwd '\picture1.jpeg']);
pause (3)
B = csvread('my_path\test2_csv.csv');
histogram(B);
pause (3)
saveas(figure(1),[pwd '\picture2.jpeg']);
pause (3)
close
clear
clc
The "bplot" is an external function that I downloaded. Any ideas how to save it in other way?

Best Answer

You should be building your file names with fullfile(). For deployed files, the default location will be relative to ctfroot(), not relative to anything belonging to the user. If, for some reason, you do want to save new content relative to ctfroot(), be careful about whether the deployment directories are writable by all users of the executable.