Hi Roberto,
You can utilize the “drawnow” command along with the “timer” function to automatically refresh the fit plot with data from your file.
The “timer” function can be set to call a function that loads the data from the file and updates the plot every minute.
The “drawnow” command ensures that MATLAB renders the current figure window immediately, updating figures and processing any pending callbacks efficiently.
function updatePlot(~, ~)
data = load('autoUpdatingFile.mat');
xData = data.xData;
yData = data.yData;
% Fit a linear model
fitObject = fit(xData, yData, 'poly1');
% Plot the fit
plot(fitObject, xData, yData);
title('Linear Fit');
xlabel('X Data');
ylabel('Y Data');
drawnow; % Update figure immediately
end
% Set up a timer to call updatePlot every minute
t = timer('ExecutionMode', 'fixedRate', 'Period', 60, 'TimerFcn', @updatePlot);
% Start the timer
start(t);