Azzera filtri
Azzera filtri

GUI Callbacks - Passing brushed data between call backs

5 visualizzazioni (ultimi 30 giorni)
I am fairly new to matlab and am creating a GUI in which I need to use the brush function, which initiates upon button press "Window", to select a certain range on a graph and then with the press of a separate button "Perform Transform", use the brushed data that was selected as an input for a wavelet transform.
It is my goal to then have a popupmenu ("Select Wavelet") for which the user can select the wavelet to be used in the wavelet transform. In other words I would also need the choice picked from the string in the popupmenu to also be implemented into the seperate button press ("Perform Trasform").
So far, I have this for the "window" button press that allows the user to use the brush data. I ended it with guidata hoping that this would allow me to access the data in the other pushbutton.
_________________________
function Window1_pushbutton_Callback(hObject, eventdata, handles)
brush on pause hBrushLine = findall(gca,'tag','Brushing'); brushedData = get(hBrushLine, {'Xdata','Ydata'}); brushedIdx = ~isnan(brushedData{1}); brushedYData = brushedData{2}(brushedIdx);
ecgDWT1(:,1)=resampad(brushedYData);
handles.ecgDWT1 = ecgDWT1;
plot(handles.QRS1_axes,ecgDWT1); set(handles.QRS1_axes,'XMinorTick','on','xlim',[1 304]);
guidata(hObject,handles.ecgDWT1); brush off
________________________________________
Next, for the "Perform Transform" it begins as follows (This button alsotakes the mean and standard deviation and plots the results but the error seems to be coming from the beginning):
________________________________________
function dwt1_pushbutton_Callback(hObject, eventdata, handles)
ecgDWT1=guidata(handles.ecgDWT1); [C,L]=wavedec(ecgDWT1,4,dmey);%Compute Multi-level DWT.
....
  1 Commento
Connor
Connor il 27 Giu 2014
When I hit the "Perform Transform button" I get these error messages:
Attempt to reference field of non-structure array.
Error in ECG_GUI>dwt1_pushbutton_Callback (line 228) handles.ecgDWT1=guidata(handles.ecgDWT1);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in ECG_GUI (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)ECG_GUI('dwt1_pushbutton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback

Accedi per commentare.

Risposta accettata

Geoff Hayes
Geoff Hayes il 27 Giu 2014
Modificato: Geoff Hayes il 27 Giu 2014
In the Window1_pushbutton_Callback, the code is updating the handles structure with ecgDWT1 as
handles.ecgDWT1 = ecgDWT1;
That statement is fine. The problem comes about when the code tries to save this user-defined data
guidata(hObject,handles.ecgDWT1);
With this line, the handles structure is being overwritten with the data handles.ecgDWT1. So when the dwt1_pushbutton_Callback function fires, the handles object is no longer a structure and the accessing of handles.ecgDWT1 fails.
What you want to do instead, is just save the updated handles object in the first callback
guidata(hObject,handles);
The handles structure has all of the data (handles, etc.) that it had before plus the ecgDWT1 data.
And to access this data, the code does not need (and shouldn't!) call guidata to get to it. Just access it through the handles structure like you would for any other field of a structure object
function dwt1_pushbutton_Callback(hObject, eventdata, handles)
ecgDWT1=handles.ecgDWT1;
% etc.
Try the above and see what happens!

Più risposte (0)

Categorie

Scopri di più su Get Started with Wavelet Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by