How to import and export data through MATLAB?

19 vues (au cours des 30 derniers jours)
L
L le 22 Nov 2016
Commenté : Walter Roberson le 27 Nov 2016
Hello everyone,
Thank you in advance for your help. Normally I don't like to ask without providing what I've tried, but I'm trying to save time on what I'm trying to do.
What I am trying to achieve is a script that can automate the process of importing excel data into Matlab and then exporting it into an Access database. Basically a spreadsheet with some data and then storing it into Access by adding said spreadsheet as a new table in said database. My only real problem is that I'm not sure on the specific Matlab functions the import and export data.
I've read about several different ways to import data, but none of them I have come across give me specific functions to string together, instead it they refer to the buttons available in Matlab's "Home" tab.
Any ideas or hints in order for me to do this correctly with ease?
If I didn't provide enough of an explanation please let me know. I greatly appreciate any tips/advice you all have to offer.
EDIT: Also, I'm not just going to sit and wait for an answer, I'll be trying to string something together and then hopefully, with your inputs, I can compare to what I've done and share it with what anyone has recommended. Thank you.
Thank you,
L
  1 commentaire
L
L le 25 Nov 2016
Modifié(e) : Walter Roberson le 26 Nov 2016
UPDATE: Still need help. First answer didn't really help.
Here is what I've got so far:
[data pathname] = uigetfile( ...
{'*.m;*.xls;*.xlt;*.xlm;*.xlsx*.fig;*.mat;*.mdl', 'Files (*.m, *.fig, *.mat, *.mdl)'; ...
'*.*', 'All Files (*.*)'}, ... 'Pick a file','C:\Users\');
stuff = importdata([pathname data]);
Previously I had xlsread instead of import data, but it wasn't grabbing the variable names (like row one has all the different names of the data, Day 1, Day 2 ,etc.). Also, the first column, column A, doesn't get pulled either (it is also full of text, John Smith, Alice Jane, etc.)
I switched to using the importdata function and that seems to work but it's output, "stuff" is a structure with two things inside. What I want is stuff to equal the data in the excel file I'm trying to pull (stuff equals the table of data, column names and row names AND data all in one).
Thank you,
L

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 23 Nov 2016
Check xlsread, xlswrite.
Also go through readtable and writetable.
  7 commentaires
L
L le 26 Nov 2016
You're awesome, thank you Walter! The "raw" part was what I wanted, at least I think. Then next step of my little goal is to then transfer the information contained in "raw" into a Microsoft Access database. I'm thinking I should be able to use some function with raw being used in it to save the data to a database. Got any pointers for that direction?
Again, thank you very much!
-L
Walter Roberson
Walter Roberson le 27 Nov 2016
Sorry, I have not worked with Microsoft Access.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by