From: Rand on
My main question is: How do I import data from a database into Matlab so that I can use the data in a code?

I have a very large data file (1 column with 60,000 rows) that I imported into MS Access and want to I import the data from this database into Matlab so that I can run my function that uses this data.

I wrote a code to connect to the server (see below) but I don't know how to reference this data in my code once I connect to the database so that I can use this data.


Code to connect to the database:
>>conn = actxserver('ADODB.Connection');
>>connString = 'Provider=Microsoft.Ace.OLEDB.12.0; Data Source = \\storage.adsroot.itcs.umich.edu\home\windat.V2\Documents\MATLAB\G100Z\database1.accdb;User Id=;Password=;';
>>conn.Open(connString);
>>sqlQuery=strcat('select top 5 * from G100Ztable');
>>res = conn.Execute(sqlQuery);
>>if res.eof,
>>disp('no results found');
>>else
>>myData = res.GetRows;
>>end
>> conn.Close;
From: Maitha on
"Rand " <allisonryan(a)lkdaero.com> wrote in message <i1o4gt$ijs$1(a)fred.mathworks.com>...
> My main question is: How do I import data from a database into Matlab so that I can use the data in a code?
>
> I have a very large data file (1 column with 60,000 rows) that I imported into MS Access and want to I import the data from this database into Matlab so that I can run my function that uses this data.
>
> I wrote a code to connect to the server (see below) but I don't know how to reference this data in my code once I connect to the database so that I can use this data.
>
>
> Code to connect to the database:
> >>conn = actxserver('ADODB.Connection');
> >>connString = 'Provider=Microsoft.Ace.OLEDB.12.0; Data Source = \\storage.adsroot.itcs.umich.edu\home\windat.V2\Documents\MATLAB\G100Z\database1.accdb;User Id=;Password=;';
> >>conn.Open(connString);
> >>sqlQuery=strcat('select top 5 * from G100Ztable');
> >>res = conn.Execute(sqlQuery);
> >>if res.eof,
> >>disp('no results found');
> >>else
> >>myData = res.GetRows;
> >>end
> >> conn.Close;

You can Export data from MS Access to Excel then read data by using xlsread function

please check the link below for Exporting Access to Excel:
http://office.microsoft.com/en-gb/access-help/import-export-and-link-data-between-access-and-excel-HP001095095.aspx#BMjmp_exportacdatatoxl

Hope this help
Maitha
From: Allison Ryan on
Thank you Maitha for replying but my data file is too large for Excel so that is why I am using MS Access. I am able to connect to the database in Matlab, but I can't figure out if there is a function to read database data such as xlsread for data from Excel.



> You can Export data from MS Access to Excel then read data by using xlsread function
>
> please check the link below for Exporting Access to Excel:
> http://office.microsoft.com/en-gb/access-help/import-export-and-link-data-between-access-and-excel-HP001095095.aspx#BMjmp_exportacdatatoxl
>
> Hope this help
> Maitha
> > My main question is: How do I import data from a database into Matlab so that I can use the data in a code?
> >
> > I have a very large data file (1 column with 60,000 rows) that I imported into MS Access and want to I import the data from this database into Matlab so that I can run my function that uses this data.
> >
> > I wrote a code to connect to the server (see below) but I don't know how to reference this data in my code once I connect to the database so that I can use this data.
> >
> >
> > Code to connect to the database:
> > >>conn = actxserver('ADODB.Connection');
> > >>connString = 'Provider=Microsoft.Ace.OLEDB.12.0; Data Source = \\storage.adsroot.itcs.umich.edu\home\windat.V2\Documents\MATLAB\G100Z\database1.accdb;User Id=;Password=;';
> > >>conn.Open(connString);
> > >>sqlQuery=strcat('select top 5 * from G100Ztable');
> > >>res = conn.Execute(sqlQuery);
> > >>if res.eof,
> > >>disp('no results found');
> > >>else
> > >>myData = res.GetRows;
> > >>end
> > >> conn.Close;
>
> You can Export data from MS Access to Excel then read data by using xlsread function
>
> please check the link below for Exporting Access to Excel:
> http://office.microsoft.com/en-gb/access-help/import-export-and-link-data-between-access-and-excel-HP001095095.aspx#BMjmp_exportacdatatoxl
>
> Hope this help
> Maitha
 | 
Pages: 1
Prev: Normalize
Next: appending data from within loop