How do I change the header name of csv files?

8 views (last 30 days)
Here are the screenshots of my code and the ouput too
  4 Comments
dunphy
dunphy on 14 Apr 2020
That is my full code. When i run it, there will always be a speed.csv file forming however the headings remain "Var1" "Var 2". How do I change it permanently?

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 14 Apr 2020
Edited: Adam Danz on 15 Apr 2020
When you write the csv file, there are no headers using the syntax you shared. The Var1 Var2.... headers appear when you read the data back into Matlab.
I suggest you convert your matrix into a table and use writetable() instead of csvwrite.
T = array2table([p(:),d(:),e(:)], 'VariableNames', {'p','d','e'})
% Replace these with meaningful variable names ^^^^^^^^^^^^^
writetable(T, 'speed.csv')

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!