Thread Subject: using uiimport to load a matrix

Subject: using uiimport to load a matrix

From: Michael Walsh

Date: 16 Nov, 2009 16:16:03

Message: 1 of 2

I'm writing an application where I want to bring a matrix into the Matlab workspace so I can run algorithms against it. I've written the software so the user can preload the matrix either in Excel.txt(tab delimited) or Matlab.mat. I wanted to use uiimport to allow the user to mouse to the directory where they stored the data and select the .txt or .mat file that has the desired input data, which happens to be a matrix. Eventually I want to have this data_load to happen after a button push on my gui, but for now I'm trying to get it to work inside a simple Matlab function. I've tried the following code, but it returns the entire matrix in a 1x1 variable.

>>bob = uiimport; %browse, select file, etc....
>> whos
  Name Size Bytes Class Attributes

  bob 1x1 1740 struct

In my case, the variable "bob" should be a 102x2 matrix. None of the Matlab documentation on uiimport shows successful syntax. Any help would be appreciated. I am currently using Matlab 7.6.0(R2008a).

Subject: using uiimport to load a matrix

From: Michael Walsh

Date: 16 Dec, 2009 18:46:04

Message: 2 of 2

I invented my own solution to this dilemna. The following three lines of code allow one to uiimport an arbitrary file_name, and then access an arbitrary column of data from that data file:

ESS = uiimport;
vars = fieldnames(ESS);
roc_matrix = ESS.(vars{1});

In my case, the matrix was the only variable I imported, so I was able to grab the first position, regardless of what the end_user called it inside the .mat or the .xls data file.

This may seem like trivial stuff for some programmers, but for an engineer who wants to dynamically import to hardcoded variable names, this worked.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
uiimport woes Michael Walsh 16 Nov, 2009 11:19:06
rssFeed for this Thread

Contact us at files@mathworks.com