uiimport help

edited February 2009 in Science & Tech
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……..


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

uiimport(input_file)



/COLOR]pathstr, name, ext, versn[COLOR=#008800 = 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.

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited February 2009
    Could you be more specific with the problem? How "wrong" are the dimensions?
  • edited February 2009
    shwaip wrote:
    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
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited February 2009
    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:
  • edited February 2009
    drasnor wrote:
    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
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited February 2009
    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:
  • edited February 2009
    drasnor wrote:
    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?
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited February 2009
    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.

    -drasnor :fold:
  • edited February 2009
    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;
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited February 2009
    I....I don't understand.
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited February 2009
    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 for delimited data files.
    * fscanf and friends for formatted data files.

    -drasnor :fold:
Sign In or Register to comment.