Automatically writing a function does not update until manually opening said function
1 次查看(过去 30 天)
显示 更早的评论
Hi,
For an application we are writing, we want the user to be able to write a controller for a certain experiment.
They can do this in an area that is indicated by 'UserbuildControllerTextArea' in the app. The controller is then put into a seperate file called 'PID_user_build.m', which is created in the following code:
function_gen = fopen('PID_user_build.m','w');
format_gen = 'function u_c = PID_user_controller(P,I,D,r,v_c,integrator,derivator,dt) \n';
fprintf(function_gen,format_gen);
A = length(app.UserbuildControllerTextArea.Value);
area = string.empty(A,0);
for i = 1:A
area(i,1) = sprintf('%s',app.UserbuildControllerTextArea.Value{i});
end
function_area = fopen('PID_user_build.m','a');
fprintf(function_area,'%s \n',area);
function_end = fopen('PID_user_build.m','a');
format_end = 'end';
fprintf(function_end,format_end);
The function file is created perfectly, it makes the file as desired with the controller neatly in the function.
The problem is that even though the file is created and saved, it is not 'updated' until the file is opened once:
A different function in the app tries to use this function, but if a new controller is saved by the script above, the app uses the old version of the controller until the file of the controller is opened (not even saved) once. It then runs the controller-function as desired.
We would like to remove this need for the file to be opened for the app to use the updated controller. Would any of you know what the problem is or how to fix it?
Thanks in advance!
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!