How can I load two data files using a function

1 visualizzazione (ultimi 30 giorni)
Stargazer
Stargazer il 4 Mar 2018
Commentato: Stargazer il 5 Mar 2018
Looking for a specific tutorial on how to generate a function that will load two excel files (same variables - different data). I'm assuming that the two files will be displayed in the command window. Can someone point me in the right direction.

Risposte (1)

Benjamin Kraus
Benjamin Kraus il 4 Mar 2018
This may help you get started: Ways to Import Spreadsheets.
In particular, the Import Tool provides an interactive workflow for reading an Excel spreadsheet. However, once you have read in the Excel spreadsheet, it can be used to generate a function that will repeat the steps for you. This function can then be used to repeat the same import automatically on additional files.
There is a tutorial that shows you how to Read Spreadsheet Data Using Import Tool. At the bottom of that tutorial is a section named: "Import Data from Multiple Spreadsheets" that sounds very similar to what you are requesting.
  3 Commenti
Benjamin Kraus
Benjamin Kraus il 5 Mar 2018
I'm not sure I understand your question. Once you've imported the data into the workspace, it is stored in one (or more) variables per spreadsheet. How it is stored depends on the mechanism you used to import the data. For example, if you used readtable, the data will be stored in one table per spreadsheet. Are you asking how to merge those two tables into a single table that includes all the data?
In order to help, can you please clarify:
  1. How are you reading the data into MATLAB? If you are using a line (or two) of code, copy/paste that code, so we can see the function name and the output variable name(s).
  2. What are the variable names/types that were created when you imported the data?
  3. What do you mean when you say "using just one function"? Are you trying to write one function that processes both sets of data?
Most likely, you can use the vertcat command to merge your data into a single variable, but the specifics will depend on your data and how it was imported.
Stargazer
Stargazer il 5 Mar 2018
Hi there. Point 3. Just cant seem to find an example/tutorial that will help me with this problem. Im keen to work through a tutorial rather than have a direct answer :-)

Accedi per commentare.

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by