How to pass string value from one callback function to another?
Ahora está siguiendo esta pregunta
- Verá actualizaciones en las notificaciones de contenido en seguimiento.
- Podrá recibir correos electrónicos, en función de las preferencias de comunicación que haya establecido.
Se ha producido un error
No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.
0 votos
Comparte un enlace a esta pregunta
Respuesta aceptada
0 votos
Comparte un enlace a esta respuesta
20 comentarios
% --- 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')
Comparte un enlace a este comentario
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);
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
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.
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
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.
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Comparte un enlace a este comentario
Más respuestas (0)
Categorías
Más información sobre Code Execution en Centro de ayuda y File Exchange.
Etiquetas
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)
