PDA

View Full Version : uiimport help


Hnc3
5 Feb 2009, 7:48pm
Hi,
I have a problem, I am using the uigetfile and uiimport to load a dataset file. after loading the dataset file I would like the output of the dimensions ie rows and column.
with the following code I am getting the wrong dimensions……..


[input_file,pathname] = uigetfile( ...
{'*.txt', 'Text (*.txt)'; ...
'*.xls', 'Excel (*.xls)'; ...
'*.*', 'All Files (*.*)'}, ...
'Select files');

uiimport(input_file)



[pathstr, name, ext, versn] = fileparts(input_file)


r = size(name,1); % number of rows
c = size(name,2); % number of columns

disp(r) % Output
disp(c) % Output</pre>

Your help would be very much appreciated. Thank you.

shwaip
6 Feb 2009, 6:57am
Could you be more specific with the problem? How "wrong" are the dimensions?

Hnc3
6 Feb 2009, 8:06pm
Could you be more specific with the problem? How "wrong" are the dimensions?


Thank you for your reply

OK instead of receiving the dimensions of the matrix/vector I am receiving the dimension of the file name.

for example the name of the file being loaded into matlab is 'student' then the dimension output for rows r and column c is

r = 1

c = 7

which is wrong its giving the dimension of the word student and not the matrix/vector

Thank you

drasnor
6 Feb 2009, 8:41pm
You're not actually reading data out of the file. When you open the import wizard with uiimport you need to use the wizard to create objects in your workspace corresponding to the data in the file. Right now you're just asking for information about the file itself.

-drasnor :fold:

Hnc3
6 Feb 2009, 8:52pm
You're not actually reading data out of the file. When you open the import wizard with uiimport you need to use the wizard to create objects in your workspace corresponding to the data in the file. Right now you're just asking for information about the file itself.

-drasnor :fold:


Yes I do want the information such as dimension of the content of the file.

If I use the file name 'student' Instead of using 'name' then I am getting the correct output but I want it to be dynamic where I can load different files and not limit it to one file..

r = size(student,1); % number of rows
c = size(student,2); % number of columns

The above code gives me the correct output but thats for just the student file.

Thank you

drasnor
6 Feb 2009, 9:12pm
What I mean is that the parameter 'name' in fileparts just gives you the filename of input_file and not its contents. If you want the rest of your code to understand the objects you create from the import wizard you need to name them something generic but consistent like 'data' and use that.

-drasnor :fold:

Hnc3
6 Feb 2009, 9:17pm
What I mean is that the parameter 'name' in fileparts just gives you the filename of input_file and not its contents. If you want the rest of your code to understand the objects you create from the import wizard you need to name them something generic but consistent like 'data' and use that.

-drasnor :fold:

Thank you

Im new to matlab how do I do that?

drasnor
6 Feb 2009, 9:26pm
When you use uiimport to parse a file it will give you a list of the data object(s) it's going to create from the file. Change whatever the default name of the object you're interested in to the name you specify in your .m file. Read more here. (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_prog/f5-91134.html)

-drasnor :fold:

afshing63
14 Feb 2009, 4:22pm
Hi.
I have a problem,
I use Import wizard for Import such date from a txt file,this can do by using a uiimport('filename') command instead of file>Import wizard from menu.
I look for a commands that do "next" and other facilities of Import wizard(such ''comma'' & "space"as commands sentences which can use in M-file for my programming;
thanks for your attention;

shwaip
15 Feb 2009, 1:06am
I....I don't understand.

drasnor
15 Feb 2009, 3:10pm
The point of uiimport is to open a user interface that allows you to choose your parsing options on the fly. As such it is NOT scriptable. If you want to parse a text data file automatically as part of your program then you should really be using:

* dlmread (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/dlmread.html) for delimited data files.
* fscanf (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/fscanf.html) and friends (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/textscan.html) for formatted data files.

-drasnor :fold: