How to pass string value from one callback function to another?
Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
0 voti
Condividi un link a questa domanda
Risposta accettata
0 voti
Condividi un link a questa risposta
20 Commenti
% --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles)
[filename,filepath]= uigetfile({'*.*';'*.wav';'*.m4a'});
fullname = fullfile(filepath, filename);
set(handles.edit6,'string', fullname);
% --- Executes on button press in button. function button_Callback(hObject, eventdata, handles) % hObject handle to button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
fullname = get(handles.edit6, 'string');
data = audioread(fullname);
L= length (data);
Y= fft(data)
P2= abs (Y/L)
P1= P2(1:L/23+1);
P1(2:end-1)= 2*P1(2:end-1)
figure= subplot('position', [0.56, 0.15, 0.4, 0.3]);
K= plot (P1);
title ('Frequency Domain')
xlabel('f(Hz)')
ylabel('P1(f)')
hold on
[y,Fs]= audioread(fullname); t= linspace(0,length(y)/Fs, length(y));
figure1= subplot('position', [0.10, 0.15, 0.4, 0.3]);
plot(t,y);
title ('Time Domain')
xlabel('Time (sec)')
ylabel('Amplitude')
I am having a problem. when i get the back button in this .fig and come back and try to browse the .wav file, it does not set the fullname in the edit text box.
Put in a breakpoint at the uigetfile and step through to see what happens. For example is handles.edit6 still a valid handle at the time of the set() ? If the set() works without error then what do you get if you then (in the debugger)
get(handles.edit6, 'string')
Condividi un link a questo commento
this is error the message that I am getting..
Undefined function or variable 'button_DeleteFcn'.
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in multiply (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)multiply('button_DeleteFcn',hObject,eventdata,guidata(hObject))
Error using multiply>figure1_CloseRequestFcn (line 140) Error while evaluating UIControl DeleteFcn.
Dot indexing is not supported for variables of this type.
Error in multiply>pushbutton7_Callback (line 248) set(handles.edit6,'string', fullname);
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Your uicontrol named button with string Train! has been configured to expect to be able to call button_DeleteFcn and button_KeyPressFcn but those do not exist.
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Please make sure you are using my versions of the .fig and the .m . Close any existing figures and "clearvars"
The fix for the back button (which has already been written into that multipy.m) was
function pushbutton2_Callback(hObject, eventdata, handles)
back_to = 'SRS01_GUI_TrainPage.fig';
if exist(back_to, 'file')
open(back_to);
close('multiply');
else
waitfor(warndlg( sprintf('Cannot go back, did not find find "%s"', back_to)));
end
That is, the reason you were failing was that the "back" button was trying to invoke SRS01_GUI_TrainPage and that did not exist. The replacement code makes sure it exists before trying to invoke it.
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Più risposte (0)
Categorie
Scopri di più su Code Execution in Centro assistenza e File Exchange
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
