How can I use guidata to pass 2 different variables in 2 different callbacks of a GUI?

4 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
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
Mayank Amencherla
Mayank Amencherla el 31 de Dic. de 2013
Well, the .mat file in question is an ema file - a spreadsheet. It just contains data in rows and columns, that's all.
Walter Roberson
Walter Roberson el 31 de Dic. de 2013
plot(ema.ema)
this is going to plot 16 lines (because you have 16 columns)

Iniciar sesión para comentar.

Más respuestas (0)

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!

Translated by