On Code Ocean, files need to be saved to /results
to be visible as results.
When you export a capsule, it will come with a /results
folder inside the exported folder. Some users may not want a new folder created for them, for example they are downloading the code and data separately rather than exporting the capsule as a whole -- and their local workflow may be to just wait for figures to pop up in their IDE or terminal.
For these use cases, you can use either shell scripting or MATLAB syntax.
Shell:
DIRECTORY='../results'
if [ -d "$DIRECTORY" ]; then
# run your code
# save your figure
fi
MATLAB:
After generating your figure, you'd run something like
if ~usejava('desktop') saveas(gcf,'../results/figure1.pdf') end
If you have other languages you'd like to see syntax for, plese communicate this via live chat or an email to support@codeocean.com, and we'll amend this article accordingly.