How to save the data from serial port continuesly through csv or xls?

6 vues (au cours des 30 derniers jours)
Eric23333
Eric23333 le 31 Juil 2017
Commenté : Eric23333 le 6 Août 2017
Hello all!
I wonder to know how can i save the data from serial port continuesly through .csv or .xls.
I have do some works before.I have used the xlswrite such as
xlswrite(name,data, 'Sheet1',str)
to save the data through change the str(change the sheet location to be written),e.g. First is A1:F10,Second is A11:F20 to achieve continuesly save.
It is useful,but i think this method looks some stupid ...
I wonder is there exist some other methods to solve this problem.
I would greatly appreciate if you kindly give me some some advice.

Réponse acceptée

Walter Roberson
Walter Roberson le 31 Juil 2017
fid = fopen('YourOutput.csv', 'wt');
while true
YourNumericData = ...
ncol = size(YourNumericData, 2);
fmt = [repmat('%g,', 1, ncol-1), '%g\n'];
fprintf(fid, fmt, YourNumericData .' ); %transpose is important
end
fclose(fid);
  1 commentaire
Eric23333
Eric23333 le 6 Août 2017
Thanks,i make some changes such as 'wt' to'a+' . And this method can solve my problem.Thanks for your Answer!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink 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!