Results 1 to 6 of 6

Math Help - Excel to Matlab!

  1. #1
    Junior Member
    Joined
    Mar 2006
    From
    Manchester
    Posts
    25

    Excel to Matlab!

    Just wondering if it is possible to take a column of values from Excel, and input them into MATLAB as a vector.

    For example i have a column of 100 values in an Excel spreadsheet that i would like to input into my program as N (N being a vector of length 100). are there any ways i can go about this? any help would be greatly apprecaited.

    Shaun Gill.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Shaun Gill View Post
    Just wondering if it is possible to take a column of values from Excel, and input them into MATLAB as a vector.

    For example i have a column of 100 values in an Excel spreadsheet that i would like to input into my program as N (N being a vector of length 100). are there any ways i can go about this? any help would be greatly apprecaited.

    Shaun Gill.
    You can export the data from Excel as a csv file, and read it in in Matlab,
    but you will have to read the documentation for the detail.

    Personaly unless this is going to be a production line job, I would open the
    csv file edit it to a Matlab vector assignment and copy to the paste buffer, and paste into Matlab.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2007
    Posts
    6
    Quote Originally Posted by Shaun Gill View Post
    Just wondering if it is possible to take a column of values from Excel, and input them into MATLAB as a vector.

    For example i have a column of 100 values in an Excel spreadsheet that i would like to input into my program as N (N being a vector of length 100). are there any ways i can go about this? any help would be greatly apprecaited.

    Shaun Gill.
    There is a function in MATLAB called xlsread.

    Let's say your excel file is named data.xls and the numbers you want are in cells A1 to A100, try this:

    N=xlsread('data.xls','A1:A100')

    It also works with Excel 2007's extensions of .xlsx
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Shaun Gill View Post
    Just wondering if it is possible to take a column of values from Excel, and input them into MATLAB as a vector.

    For example i have a column of 100 values in an Excel spreadsheet that i would like to input into my program as N (N being a vector of length 100). are there any ways i can go about this? any help would be greatly apprecaited.

    Shaun Gill.
    Simplest is to export the Excel data as csv, and read that with Matlab.

    Also I'm pretty sure Matlab is able to read Excel files but don't have a copy
    this machine to check.

    Google tells me the function is xlsread.

    RonL
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Nov 2007
    Posts
    30
    I've got a student version of matlab 5... and when I write

    N=xlsread('data.xls','A1:A100')

    it spits out an error

    ??? Undefined function or variable 'xlsread'.

    I've just started using matlab but my guess is that I don't have the .m file for xlsread? How do I solve this prob?

    I've tried getting the column of data from a .csv file using csvread but it comes out with a heap of errors which I've looked up and theyve just boggled my mind as to what they mean.

    EDUğ m = csvread('data.csv',0,0)
    ??? Subscripted assignment dimension mismatch.

    Error in ==> c:\program files\matlab\toolbox\matlab\iofun\dlmread.m
    On line 95 ==> m(loc(2)+r, loc(1)+c) = setstr(num);

    Error in ==> c:\program files\matlab\toolbox\matlab\iofun\csvread.m
    On line 40 ==> m=dlmread(filename, ',', r, c);

    I've looked up the "subscripted assignment dimension mismatch" and yer its kind of confusing as to how to fix the prob. So I think opening the csv file with excel converting it into an excel doco and accessing it using the xlsread is much easier. But essentially I've got the same general question as Shaun Gill.

    Also, I personally don't quite know what CaptainBlack meant by "Personaly unless this is going to be a production line job, I would open the
    csv file edit it to a Matlab vector assignment and copy to the paste buffer, and paste into Matlab."
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    May 2008
    Posts
    1

    Post Hi

    i have joined this forum lately.. i notice that it is a very old thread but i will respond to it anyway..

    xlsread is a function that can be found by default in Matlab ver 7.3 to 7.6 but not in Matlab ver 6.5 and below.. if you needed it U can get it from www.mathwork.com in file exchange where this function can be found easily and U should save it in m file having the same name to work properly.. I advice to use another advance function xlsread8 or xlswrite8 because it has more flexibility.. Read the help that come with it to use it better
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. help in excel
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 26th 2011, 05:29 AM
  2. Importing Excel sheet into Matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 20th 2011, 11:41 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. MATLAB excel import troubles
    Posted in the Math Software Forum
    Replies: 6
    Last Post: February 5th 2009, 06:44 AM

Search Tags


/mathhelpforum @mathhelpforum