writing multiple rows to excel sheet
Mostra commenti meno recenti
I have a dataset. I extracted features from it. Now I want to write it into an excel sheet. But only last row of combined vector is writing into excel file.I put xlswrite() function after loop only. How can solve this problem?
7 Commenti
Bob Thompson
il 5 Mar 2020
Please copy your code here. It sounds like you aren't indexing properly within your loop, and are not saving all of the data to be written.
Sajitha K.N.
il 5 Mar 2020
darova
il 5 Mar 2020
I don't understand: what is the problem?
Sajitha K.N.
il 5 Mar 2020
darova
il 5 Mar 2020
This line throws me an error

Can you please use attachment button for long code?
Sajitha K.N.
il 5 Mar 2020
Modificato: Sajitha K.N.
il 5 Mar 2020
darova
il 5 Mar 2020

Risposte (1)
Walter Roberson
il 5 Mar 2020
xlswrite('Grape_blackMeasles.xlsx', combined_vector)
Tells MATLAB to overwrite all of the sheet 1 in that xlsx file with the current content of combined_vector.
There is no option for xlswrite() or writetable() or related functions to append to an xlsx file from where-ever the current end happens to be. You have two options:
- read in all of the current content, append your new data in memory, and write out the combined data; or
- somehow figure out where the end of the current content is, and use the range specification of xlswrite() or writetable() to tell MATLAB where to write the new data.
If you are writing data in a loop starting from an empty sheet, then you can keep track of how many rows you have written so far in order to know where to start writing new rows.
Categorie
Scopri di più su Agriculture in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!