How to create next and back push buttons in Guide Matlab -
i'm making gui, , i'm using guide it. before writing question, have explain details, are: -kind of data: text file, info emg of 16 muscles of 2 human's legs, have plot 16 graphs. -objective of gui show 4 in each "page", need next , force button able see 16 graphs.in other words, gui needs 4 "pages". -my guide made of 1 force bottom browser data, 1 force bottom switch(update) shape of 4 graphs showed wave in abs, graphs envelope, , combination of abs & enveloped graphs, 1 popmenu switch shapes of showed graphs, , 2 force bottom, 1 next button , 1 button.
to sum up, i'm stuck in how create next , button. others roles of code have been developed.
thanks in advance.
ps: person suggested improve question.
yes, want redraw graphs(my english language not good, couldn't explain better)
->>>>>>> browser function
function search_patient_callback(hobject, eventdata, handles) % hobject handle search_patient (see gcbo) % eventdata reserved - defined in future version of matlab % handles construction handles , user info (see guidata) % hint: get(hobject,'value') returns toggle state of search_patient global cell_data [file, path]=uigetfile('*.txt', 'select file'); arq = [path,file]; full_pathname=strcat(path,file); text=fileread(full_pathname); cell_data= textscan(text, repmat('%f',1,41),'headerlines',11); delimiter = '\t'; startrow = 3; endrow = 8; formatspec = '%*s%*s%*s%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%[^\n\r]'; fileid = fopen(arq,'r'); textscan(fileid, '%[^\n\r]', startrow-1, 'returnonerror', false); dataarray = textscan(fileid, formatspec, endrow-startrow+1, 'delimiter', delimiter, 'returnonerror', false); time_foot1 = dataarray{:, 1}; %h = handles.search_patient; %setappdata(0,'my_main_data',cell_data) setappdata(0,'time_foot',time_foot1) handles = guidata(hobject); %updating variables guidata(hobject,handles); %updating variables ->>>>>>>it updating function.
function updating_callback(hobject, eventdata, handles) % hobject handle updating (see gcbo) % eventdata reserved - defined in future version of matlab % handles construction handles , user info (see guidata) global cell_data y_data=0.001; t=(cell_data{1,1})/1000; time_foot1= getappdata(0,'time_foot'); text_rfoot=0.0009; text_lfoot=0.0007; [emg1_1 emg2_1 emg3_1 emg4_1 emg1e_1 emg2e_1 emg3e_1 emg4e_1]=emg_signal(cell_data); % emg rms , emg envelope popup_sel_index = get(handles.popupmenu, 'value'); switch popup_sel_index case 1 axes (handles.axes1); plot (t,emg1_1,'r-'); title('emg left vastus medialis : ' ) xlabel('time(s)') ylabel('voltage (uv)') axes (handles.axes2); plot (t,emg2_1,'r-'); axes (handles.axes3); plot (t,emg3_1,'r-'); axes (handles.axes4); plot (t,emg4_1,'r-'); axis ([t(1) (t(1)+(length (t')/1000)) 0 y_data]) %right-foot strike1 text(time_foot1(4),text_rfoot, ' right-strike 1', 'color', 'k') line('xdata',[time_foot1(4) time_foot1(4)], 'ydata', [0 y_data], 'linestyle', '-','linewidth', 1, 'color','k'); %right foot off text(time_foot1(6),text_rfoot, ' right-off', 'color', 'k') line('xdata',[time_foot1(6) time_foot1(6)], 'ydata', [0 y_data], 'linestyle', '-','linewidth', 1, 'color','k'); %right-foot strike2 text(time_foot1(5),text_rfoot, ' right-strike 2', 'color', 'k') line('xdata',[time_foot1(5) time_foot1(5)], 'ydata', [0 y_data], 'linestyle', '-','linewidth', 1, 'color','k'); %left-foot strike text(time_foot1(1),text_lfoot, ' left-strike', 'color', 'b') line('xdata',[time_foot1(1) time_foot1(1)], 'ydata', [0 y_data], 'linestyle', '-','linewidth', 1, 'color','b'); %left foot off text(time_foot1(3),text_lfoot, ' left-off', 'color', 'b') line('xdata',[time_foot1(3) time_foot1(3)], 'ydata', [0 y_data], 'linestyle', '-','linewidth', 1, 'color','b'); title('emg left vastus medialis : ' ) xlabel('time(s)') ylabel('voltage (uv)') case 2 axes (handles.axes1); plot (t,emg1e_1,'b-','linewidth', 2); title('emg left vastus medialis : ' ) xlabel('time(s)') ylabel('voltage (uv)') axes (handles.axes2); plot (t,emg2e_1,'b-','linewidth', 2); axes (handles.axes3); plot (t,emg3e_1,'b-','linewidth', 2); axes (handles.axes4); plot (t,emg4e_1,'b-','linewidth', 2); case 3 axes (handles.axes1); plot (t,emg1_1,'r-'); hold on plot (t,emg1e_1,'b-','linewidth', 2); hold off axes (handles.axes2); plot (t,emg2_1,'r-'); hold on plot (t,emg2e_1,'b-','linewidth', 2); hold off axes (handles.axes3); plot (t,emg3_1,'r-'); hold on plot (t,emg3e_1,'b-','linewidth', 2); hold off axes (handles.axes4); plot (t,emg4_1,'r-'); hold on plot (t,emg4e_1,'b-','linewidth', 2); hold off end a=get(handles.next_pushbutton,'value') handles = guidata(hobject) guidata(hobject,handles); ->>>>>>>>>popmenu function
function popupmenu_createfcn(hobject, eventdata, handles) % hobject handle popupmenu (see gcbo) % eventdata reserved - defined in future version of matlab % handles empty - handles not created until after createfcns called % hint: popupmenu controls have white background on windows. % see ispc , computer. if ispc && isequal(get(hobject,'backgroundcolor'), get(0,'defaultuicontrolbackgroundcolor')) set(hobject,'backgroundcolor','white'); end set(hobject, 'string', {'emg_abs','emg_envelope','emg_abs + emg_envelope'}) set(hobject, 'string', {'emg_abs','emg_envelope','emg_abs + emg_envelope'})
all code here, , don't know if have done best way programme in matlab because first gui i'm making, , have lot of doubts.
thanks
let me right code show little mistakes made (i'm not experienced think can help you). didn't seek understand textscan(...) calls since don't have 1 of txt files.
function search_patient_callback(hobject, eventdata, handles) % global cell_data (i avoid global variables) [file, path]=uigetfile('*.txt', 'select file'); % arq = [path,file]; (it same below, no ?) full_pathname=strcat(path,file); text=fileread(full_pathname); cell_data= textscan(text, repmat('%f',1,41),'headerlines',11); delimiter = '\t'; startrow = 3; endrow = 8; formatspec = '%*s%*s%*s%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%[^\n\r]'; fileid = fopen(full_pathname,'r'); textscan(fileid, '%[^\n\r]', startrow-1, 'returnonerror', false); dataarray = textscan(fileid, formatspec, endrow-startrow+1, 'delimiter', delimiter, 'returnonerror', false); time_foot1 = dataarray{:, 1}; % store relevant info in handles construction : handles.timefoot=timefoot1; handles.cell_data=cell_data; guidata(hobject,handles); % line saves current handles (so saves changes above) % handles = guidata(hobject); % line replaces current handles 1 stored. utilize in origin of function doesn't take handles input, or after phone call function affects handles. then
function updating_callback(hobject, eventdata, handles) y_data=0.001; t=(handles.cell_data{1,1})/1000; % else can 'cell_data=handles.cell_data;' , utilize 'cell_data' did %time_foot1= getappdata(0,'time_foot'); (let utilize handles construction instead of getappdata) time_foot1=handles.time_foot; text_rfoot=0.0009; text_lfoot=0.0007; [emg1_1 emg2_1 emg3_1 emg4_1 emg1e_1 emg2e_1 emg3e_1 emg4e_1]=emg_signal(handles.cell_data); % emg rms , emg envelope popup_sel_index = get(handles.popupmenu, 'value'); switch popup_sel_index [skipping few lines] end % a=get(handles.next_pushbutton,'value') (what ??) % handles = guidata(hobject) (you not want erase handles construction ?) guidata(hobject,handles); % ok not neccesary because nil changed in handles construction in function) now what want do modifying updating function takes business relationship number of times pushed previous/back. think. create simple variable handles.index=1 within gui openingfcn (don't forget save guidata) , every time force 1 of buttons modify value (+1 or -1). within updating function, newindex=mod(handles.index,4); , newindex tells "plane" have show.
an alternate solution utilize popupmenu strings {'1','2','3','4'} instance, , utilize use already.
matlab matlab-guide
No comments:
Post a Comment