Sitemap

A list of all the posts and pages found on the site. For you robots out there is an XML version available for digesting as well.

Pages

Posts

Matlab skills

less than 1 minute read

Published:

How to add a header to a matrix and write it to a csv or excel file?

We save the matrix using the format of table to combine various data types. Related code:

%% Method 1
csvname='xxx.csv';
columns = {'A', 'B', 'C'};%Note that the number of rows in the A, B, and C matrices is the same, and each represents a column of data with different data types
data = table(A, B, C,'VariableNames', columns); % Create a table-type variable **data** based on these individual variables
writetable(data,csvname);%export to csv file
writetable(data,xlsname);%export to excel file
%% Method 2
A=[1 2 3;4 5 6]
T = array2table(A)%arrat to table
T.Properties.VariableNames(1:3) = {'x_axis','y_axis','z_axis'}%note the number of cols
writetable(T,'file.csv')

Ref:

https://ww2.mathworks.cn/matlabcentral/answers/281150-writing-a-matrix-with-header-into-a-csv-file https://www.zhihu.com/question/39707220

Blog Test

less than 1 minute read

Published:

This is a sample blog post. Lorem ipsum I can’t remember the rest of lorem ipsum and don’t have an internet connection right now. Testing testing testing this blog post. Blog posts are cool.

portfolio

publications

talks

teaching