How to batch processing the answers from MATLAB to Excel
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hong Wei Tang
le 19 Juin 2021
Modifié(e) : Prateek Rai
le 29 Juil 2021
Greetings. I have several questions that i want to ask for you guys.
- How to import data from Excel? I used to utilise the function readmatrix() to read the data for particular column.
- How to use the data that I imported from Excel to perform batch processing? For instance, I've already imported years, months and days from Excel to MATLAB, now I need to perform calculations in MATLAB, and export every answers back to Excel after I got every answers by using formula.
- I think that the loop function would be involved in this case.
Here is a simple example:
I have many data in Excel:
Year Month Day
2001 1 1
2002 2 2
2003 3 3
I want to import these data above to MATLAB.
After that, I want to use these data to perform several calculation by using the formulas below:
Total=year+month+day
Something=Total-somethingelse
Once I get the answer which is 'something', I want to send back the result back to Excel. In this simple example, I will get 3 answers. I think the results will be shown like this below:
Something
2003
2006
2009
I think the loop function would be appeared in the coding. I have been searching this issue such a long time, please help me, and thanks for spending time to read and solve this question. Have a great day!
1 commentaire
dpb
le 19 Juin 2021
These are all trivial pieces individually, just string them together. See
for starters...
Réponse acceptée
Prateek Rai
le 29 Juil 2021
Modifié(e) : Prateek Rai
le 29 Juil 2021
To my understanding, you want to do the following tasks:
- import data from excel sheet into MATLAB.
- do some processing on imported data and export back to excel sheet.
- wants to know if loop is involved or not.
(1) For importing data you can use readtable function.
For your example:
p = readtable("Simple Example.xlsx")
where Simple Example.xlsx is the name of example file.
(2) After importing data, you can use:
p.Total = p.Year + p.Month + p.Day
writetable(p,"Simple Example.xlsx")
(3) Using loop is not necessary here.
You can refer to readtable MathWorks documentation page to find more on readtable function and writetable MathWorks documentation page to find more on writetable function.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!