How to save results into csv file

1 view (last 30 days)
Nivodi
Nivodi on 22 Jul 2018
Commented: Nivodi on 23 Jul 2018
Hello everyone, I have a csv file (9X15). At the 15th column, I have times and I converted them in seconds. How can I add/save these results (from the command window)into a new column (16th) at the same csv file.? Thank you very much

Accepted Answer

Image Analyst
Image Analyst on 22 Jul 2018
Stitch the column onto the right side, and then call csvwrite():
m16Cols = [m15Cols, column16]; % Stitch column16 onto existing 15 column matrix.
csvwrite(filename, m16Cols);
  3 Comments
Image Analyst
Image Analyst on 22 Jul 2018
You didn't say they were tables before. Try using join() or outerjoin(), but it should work as is. Then use writetable() instead of csvwrite().
What are the data types of m15Cols and column16? They should both be tables. Evidently one of them is NOT a table - it's probably a regular double vector or something. Here is a demo:
load patients % Load built-in demo data.
T4 = table(Age,Height,Weight,Systolic, ...
'RowNames',LastName)
T1 = table(Diastolic)
Tboth = [T4, T1]
writetable(Tboth, filename);
Nivodi
Nivodi on 23 Jul 2018
Thank you very much for your help!

Sign in to comment.

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!