fit plot automatic refreshing
조회 수: 2 (최근 30일)
이전 댓글 표시
hello everybody
in curve fitting window I have a fit plot with data imported from a file in workspace. this file refreshes automatically every 1 min thanks to a timer.
is there a way to automatically refresh the fit plot any time the file connected refreshes? so avoiding to load data manually from workspace every minute
댓글 수: 0
답변 (1개)
Meet
2024년 9월 4일
편집: Meet
2024년 9월 4일
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!