How to save results into csv file
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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
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);
More Answers (0)
See Also
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!