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);endpause(0.5)function GUIUpdate(obj,event,handles)global x y1 y2Window_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
endendfunction gui_OpeningFcn(hObject, eventdata, handles, varargin)global y1 y2 xx = 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);
Best Answer