Gui Guide Timer Stop and Start
4 ビュー (過去 30 日間)
古いコメントを表示
Septimus Boshoff
2020 年 3 月 21 日
コメント済み: Septimus Boshoff
2020 年 3 月 24 日
Hi,
I have a gui which reads in data from a binary file and then plots it. I created a timer which should read the binary file and then updates the plot, however I run into an error when I would like to stop the timer and the updating. {Matrix dimensions must agree}. Starting the timer does not give an error
% --- Executes on button press in Start_Button.
function Start_Button_Callback(hObject, eventdata, handles)
t = handles.timer;
disp(t.Running);
if get(t, 'Running') == 'off'
start(handles.timer);
elseif get(t, 'Running') == 'on'
disp('xfdgh');
stop(handles.timer);
end
pause(0.5)
function GUIUpdate(obj,event,handles)
global x y1 y2
Window_buffer_Matrix = read_bin_file(Rows_in_database, ...
Dynamic_Database_buffer_size); % a function that reads in the data into a matrix
[~, cols_of_data] = size(Window_buffer_Matrix);
if cols_of_data > 0 && x(1,1) ~= Window_buffer_Matrix(1,1)
x = Window_buffer_Matrix(1,1:cols_of_data); % the x axis data
y1 = Window_buffer_Matrix(2,1:cols_of_data); % plotting two sets of data on one axis
y2 = Window_buffer_Matrix(2 + i,1:cols_of_data);
handles.plot = plot(handles.axes1,x,y1, 'b',...
1 + x, y2, '-.r'); % y2 is the forecasted values of y1, hence x + 1
end
end
function gui_OpeningFcn(hObject, eventdata, handles, varargin)
global y1 y2 x
x = 0;
y1 = 0;
y2 = 0;
handles.plot = plot(handles.axes1,x,y1, 'b',...
1 + x, y2, '-.r');
axes(handles.axes1);
ylabel('VRMS [pu]');
xlabel('Time step');
ylim([0.95 1.05]);
legend('Actual','Predicted')
title('Voltage Magnitude');
grid on;
handles.timer = timer('ExecutionMode','fixedRate',...
'Period', 0.5,...
'TimerFcn', {@GUIUpdate,handles});
handles.output = hObject;
guidata(hObject, handles);
2 件のコメント
Geoff Hayes
2020 年 3 月 24 日
Septimus - do you know which line of code correspods to the error? It is in the GUIUpdate callback function? Or is it at some other line?
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!