How to pass string value from one callback function to another?
Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
0 votes
Partagez un lien vers cette question
Réponse acceptée
0 votes
Partagez un lien vers cette réponse
20 commentaires
% --- 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')
Partagez un lien vers ce commentaire
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);
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
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.
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
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.
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Plus de réponses (0)
Catégories
En savoir plus sur Code Execution dans Centre d'aide et File Exchange
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
