Results 1 to 7 of 7

Math Help - MATLAB excel import troubles

  1. #1
    Newbie
    Joined
    Feb 2009
    Posts
    5

    MATLAB excel import troubles

    Lately, I have been playing around with the Excel spreadsheet import functions. What I am trying to do is to import both text and numerical values, and then have each text column correspond to each numerical column. For instance:

    Let us assume that we have a excel speadsheet:

    first column second column
    Text A 10
    Text B 20
    Text C 30

    While [text, data] = xlsread('name of spreadsheet') pulls both the text and the numerical value from the excel spreadsheet, it does so assigning "name = A B C" and "data = 10 20 30" Is there a way to automatically assign "A = 10, B = 20, C = 30"?

    I apologize if this has been asked before. I have searched far and wide, without finding the answer. The Matlab help file also comes up empty on this.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by fluxx2 View Post
    Lately, I have been playing around with the Excel spreadsheet import functions. What I am trying to do is to import both text and numerical values, and then have each text column correspond to each numerical column. For instance:

    Let us assume that we have a excel speadsheet:

    first column second column
    Text A 10
    Text B 20
    Text C 30

    While [text, data] = xlsread('name of spreadsheet') pulls both the text and the numerical value from the excel spreadsheet, it does so assigning "name = A B C" and "data = 10 20 30" Is there a way to automatically assign "A = 10, B = 20, C = 30"?

    I apologize if this has been asked before. I have searched far and wide, without finding the answer. The Matlab help file also comes up empty on this.
    I don't think you want to do this as you would not know what the variable names were going to be so could not use them subsequently. If you know that they will be A, B and C in some order then to determin that order and assign them to variables of that name you will have to parse the string array that holds them to determine the actual order.

    .
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Feb 2009
    Posts
    5
    Well the idea is that the text corresponds to the numeric value to the right of it in the actual Excel file.

    Imagine, for instance, an Excel balance sheet with the account "Cash" in the left column and the amount of cash in the right column. Once the Excel spreadsheet is loaded into MATLAB, the end user would just be able to type Cash and have the value of cash returned to him or her.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Feb 2009
    Posts
    5
    I might have misunderstood your answer.

    Let us assume that i load the variables into MATLAB. I now have "name = A B C" and "data = 10 20 30". Is there a way to have MATLAB show these variables next to each other, like a matrix, although they do not necessarily have to be linked. You can do it with numbers, of course, but what about numbers and text.

    Illustration of what I would like MATLAB to show:

    A 10
    B 20
    C 30
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by fluxx2 View Post
    I might have misunderstood your answer.

    Let us assume that i load the variables into MATLAB. I now have "name = A B C" and "data = 10 20 30". Is there a way to have MATLAB show these variables next to each other, like a matrix, although they do not necessarily have to be linked. You can do it with numbers, of course, but what about numbers and text.

    Illustration of what I would like MATLAB to show:

    A 10
    B 20
    C 30
    I don't use them myself, but I think a cell array might be what you want (you will have to look this up in the documentation)

    .
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Feb 2009
    Posts
    5
    Thank you I will look into it. Cheers!
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Feb 2009
    Posts
    5
    I have manage to make a cell array of both lists of data.

    "listData = {text(1,1:end) data}"

    The question is then how one could pull the the stringts vertically and have the first cell text correspond to the second cell data. In other words, text = data.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Importing Excel sheet into Matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 20th 2011, 11:41 AM
  2. Import images from several location
    Posted in the LaTeX Help Forum
    Replies: 2
    Last Post: July 12th 2010, 06:53 AM
  3. Excel to matlab
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 20th 2010, 11:27 PM
  4. From Matlab to Excel
    Posted in the Math Software Forum
    Replies: 3
    Last Post: February 3rd 2010, 02:20 AM
  5. Excel to Matlab!
    Posted in the Math Software Forum
    Replies: 5
    Last Post: May 25th 2008, 02:00 PM

Search Tags


/mathhelpforum @mathhelpforum