MATLAB: Does using REFRESHDATA in the stand-alone application compiled with MATLAB Compiler 4.4 (R2xxxx) cause a run-time error

basecallerMATLABworkspace

When I use REFRESHDATA in my stand-alone application compiled with MATLAB compiler 4.4, I receive the following error at run-time:
??? Error using ==> refreshdata
Could not refresh ZData from 'z'.
Error in ==> myfile at 7
refreshdata(h);
>> myfile
??? Error using ==> refreshdata
Could not refresh ZData from 'z'.
Error in ==> myfile at 8
refreshdata(h);
Reproduction Steps:
Note: You do not need to create a stand-alone application; simply calling REFRESHDATA in a MATLAB function returns the error. For example, if you put the code from the documentation into a function:
function myfile()
z = peaks(5);
[c h] = contour(z,'ZDataSource','z');
drawnow
pause(3) % Wait 3 seconds and the graph will update
z = peaks(20);
drawnow;
refreshdata(h);

Best Answer

REFRESHDATA is supported by the MATLAB compiler. The issue is not due to the usage of REFRESHDATA in a stand-alone application since it is reproducible in a MATLAB function. The issue that you are facing is probably due to the usage of the following syntax:
refreshdata(handle);
This defaults to the base MATLAB workspace where the variable will not be found since you are calling REFRESHDATA from a function. The correct syntax to use in this case is:
refreshdata(handle,'caller');
This behavior is expected and can be found in the documentation for REFRESHDATA by typing:
doc refreshdata