writing a function to load mat files and then writing a callback for it

  • Follow


Hi,
I am new to matlab programming so please bear with me. I have saved mat files that I would like to load within a gui. I first need to write a function for these files so I can then write a callback for a push button within my gui. 
I am currently testing out writing the function as
fileName = 'whatever'
var1 = xxx
var2 = yyy (*note the reason for labeling my variables is that within the mat file I only want to show values "xxx" and "yyy" all other variables within the mat file are not needed)
s = load('whatever', 'var1', 'var2');

when I "evaluate selection" It displays what I want in the command window except there is an error using load
"Unable to read file fileName: No such file or directory."
what did I do wrong?
Thanks so much for any help
0
Reply Lanelle 10/4/2010 3:53:04 PM

> fileName = 'whatever'
> s = load('whatever', 'var1', 'var2');
> "Unable to read file fileName: No such file or directory."

Is 'whatever' the full path?
I guess the GUI's folder is an other than the folder the variables are stored to.
Try using the full path.

Any other problems or wishes?
0
Reply Janis 10/7/2010 11:45:05 AM


"Janis Doebler" <janis.doebler@tu-berlin.de> wrote in message <i8kbs1$843$1@fred.mathworks.com>...
> > fileName = 'whatever'
> > s = load('whatever', 'var1', 'var2');
> > "Unable to read file fileName: No such file or directory."
> 
> Is 'whatever' the full path?
> I guess the GUI's folder is an other than the folder the variables are stored to.
> Try using the full path.
> 
> Any other problems or wishes?

Thank you for replying. I actually did solve the issue using 
fileName = 'whatever.mat'
load('whatever','xxx','yyy')
whos('-file','whatever.mat')
var1 = xxx
var2 = yyy

s = whos(fileName,'var1','var2');
My next issue is writing a function for this in order to load the specific values when I open my .mat file using uigetfile

Right now in a test gui I for my pushbutton callback, I have:

handles.fileName = uigetfile('*.mat')
guidata(hObject, handles)
setPopupmenuString(handles.popupmenuCalc, eventdata, handles)

function setPopupmenuString(hObject, eventdata, handles)
fileName = handles.fileName

what do I need to add to this code for my callback to display my mat files in the form above.
0
Reply Lanelle 10/7/2010 3:28:04 PM

"Lanelle " <woodey@umd.edu> wrote in message <i8kou4$j9v$1@fred.mathworks.com>...
> "Janis Doebler" <janis.doebler@tu-berlin.de> wrote in message <i8kbs1$843$1@fred.mathworks.com>...
> > > fileName = 'whatever'
> > > s = load('whatever', 'var1', 'var2');
> > > "Unable to read file fileName: No such file or directory."
> > 
> > Is 'whatever' the full path?
> > I guess the GUI's folder is an other than the folder the variables are stored to.
> > Try using the full path.
> > 
> > Any other problems or wishes?
> 
> Thank you for replying. I actually did solve the issue using 
> fileName = 'whatever.mat'
> load('whatever','xxx','yyy')
> whos('-file','whatever.mat')
> var1 = xxx
> var2 = yyy
> 
> s = whos(fileName,'var1','var2');
> My next issue is writing a function for this in order to load the specific values when I open my .mat file using uigetfile
> 
> Right now in a test gui I for my pushbutton callback, I have:
> 
> handles.fileName = uigetfile('*.mat')
> guidata(hObject, handles)
> setPopupmenuString(handles.popupmenuCalc, eventdata, handles)
> 
> function setPopupmenuString(hObject, eventdata, handles)
> fileName = handles.fileName
> 
> what do I need to add to this code for my callback to display my mat files in the form above.
0
Reply woodey (12) 10/8/2010 4:29:07 PM

3 Replies
307 Views

(page loaded in 0.074 seconds)

Similiar Articles:













7/21/2012 11:40:47 PM


Reply: