Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Selected Loading using listdlg

248 views
Skip to first unread message

Robert Nemec

unread,
May 30, 2000, 3:00:00 AM5/30/00
to
Hello,
I want to use the selection dialog box for loading multiple files
(e.g. *.dat-files ( ASCII)
This little example is shown in the matlab helpdesk (keyword "listdlg" )

***************
d = dir;
str = {d.name};
[s,v] = listdlg (' PromptString', 'Select a file:' ...
' SelectionMode', 'multiple',
... %single,
multiple -Selection Mode is possible
'ListString' str)
***************
My filelist:
abc.dat
xyz.dat
aa.dat
....
...etc.

Running the example brings out the selection box so that I choose some
files (e.g. second, third). As a result I get
Selection: s = [2 3]
ok: v = [1]


My Question is how I can utilize this information to load these selected
files ?
If it is not possible do you know any other way ??


Hope somebody can help me
Thanks

Robert


Jordan Rosenthal

unread,
May 30, 2000, 3:00:00 AM5/30/00
to
Robert,

You can use the values returned in s to index into the str cell:

[s,v] = listdlg(......)
if v
for i = 1:length(s)
load( str{i} );
end
end

Hope that helped,

Jordan

"Robert Nemec" <robn...@linux.zrz.TU-Berlin.DE> wrote in message
news:3933A0AC...@linux.zrz.TU-Berlin.DE...

robn...@linux.zrz.tu-berlin.de

unread,
Jun 2, 2000, 3:00:00 AM6/2/00
to
Jordan,
thanks for fast answer at first.
I tested out your procedure. There one little problem.
Starting the Listdlg gives out:
My FileList: abc.dat
xxx.dat
ttt.dat
hhh.dat
xyz.dat

When I choose e.g the last two files (s=[4 5] v= [1])
the programm gives out the first two files.
I think that means that the procedure uses just the number of elements
of "s"
and not its values isn't it ?
For loading the selected files I need access to each element of "s".
The highest value of "s" is set to "i".
When the loop starts the counter has to be compared with each element of
"s".
When the value of the counter is equal with an element of "s" the file
is given
out.
What do you think about this way, is it possible ?

If there is no solution I try to avoid this problem in using your
procedure to load the list of all my selected *.dat files in an extra
path (That works very well !!!).
Thanks a lot for your help Jordan.

Robert

PS:I hope my description was clear

Jordan Rosenthal

unread,
Jun 2, 2000, 3:00:00 AM6/2/00
to
Robert,

Whoops, there was a mistake in the code I wrote. It should be:

d = dir;
str = {d.name};

[s,v] = listdlg('promptstring','select a
file:','selectionmode','multiple','liststring',str)


if v
for i = 1:length(s)

load( str{ s(i) } );
end
end

I had mistakenly used str{i} instead of str{s(i)}. I guess you could take
advantage of Matlab's generalized FOR loops and write it this way as well:

d = dir;
str = {d.name};

[s,v] = listdlg('promptstring','select a
file:','selectionmode','multiple','liststring',str)
if v
for idx = s
load( str{ idx } );
end
end


Hope that helped,

Jordan

<robn...@linux.zrz.tu-berlin.de> wrote in message
news:3937DC65...@linux.zrz.tu-berlin.de...

Robert Nemec

unread,
Jun 7, 2000, 3:00:00 AM6/7/00
to
It works very well !!!
I can't believe that the solution is so simple.
Maybe, I need more practice matlab syntax.

Thanks a lot for your help Jordan.

Robert

ho songye

unread,
Sep 22, 2010, 9:00:39 PM9/22/10
to
Robert Nemec <robn...@linux.zrz.TU-Berlin.DE> wrote in message <3933A0AC...@linux.zrz.TU-Berlin.DE>...


Hello everyone, I am currently working on this project, where I utilized listdlg for user to make selection. I am using single selection, but I faced problem in writing callback function. I get this error:Error while evaluating uicontrol Callback.

I am wondering how I can get the information from user's selection(images from computer files) and display it in axes.

Thanks in advance :):):)

0 new messages