How can I use guidata to pass 2 different variables in 2 different callbacks of a GUI?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Mayank Amencherla
 el 30 de Dic. de 2013
  
    
    
    
    
    Comentada: Walter Roberson
      
      
 el 31 de Dic. de 2013
            My GUI is required to-
Browse for .mat and .wav files. Store the file names in storedStructure and storedStructure1.
Use load and wavread in seperate callbacks and plot those 2 functions.
Upon loading the .wav file, I plotted it without any problems. But there are problems with the .mat file.
Here's my code:
startingFolder = 'C:\Users\Mayank\Desktop\Matlab';
% Get the name of the mat file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.mat');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a mat file');
if baseFileName == 0
  % User clicked the Cancel button.
  return;
end
fullFileName = fullfile(folder, baseFileName);
storedStructur = fullFileName;
handles.b = storedStructur;
guidata(hObject,handles);
axes(handles.Sensor);
ema = load(handles.b);
plot(ema);
The error being-
Error using plot
Not enough input arguments.
Error in Speech_Proc>pushbutton10_Callback (line 149)
plot(ema);
Error in gui_mainfcn (line 96)
        feval(varargin{:});
Error in Speech_Proc (line 42)
    gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)Speech_Proc('pushbutton10_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 30 de Dic. de 2013
        When you load() a .mat file, the result is a structure with fields named after the variables stored in the file. When you plot() you need to specify which field to plot. For example if what was stored in the .mat file was a variable named "sound_data", then you would
plot(ema.sound_data);
2 comentarios
  Walter Roberson
      
      
 el 31 de Dic. de 2013
				plot(ema.ema)
this is going to plot 16 lines (because you have 16 columns)
Más respuestas (0)
Ver también
Categorías
				Más información sobre Graphics Object Programming en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


