How can I save .mat to .csv file

6 ビュー (過去 30 日間)
Mira le
Mira le 2019 年 12 月 22 日
回答済み: Image Analyst 2019 年 12 月 22 日
I have a struct of name pop has diferent field saved as .mat I want to transform it as .csv file
How do I do that?
thanks.
  1 件のコメント
dpb
dpb 2019 年 12 月 22 日
What is content of field in question? If a numeric array, the simple csvwrite is hard to beat; otherwise somewhat more complex.
But, I always have to ask...is it really necessary to actually create the other file? What can you do with it you can't do simply by loading the .mat file and using the data therein as they are?

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2019 年 12 月 22 日
Did you try using brackets to string together all the fields into a vector and then concatenate and then use csvwrite()
field1Vec = [pop.field1];
field2Vec = [pop.field2];
data = [field1Vec, field2Vec]; % Make 2-D matrix.
csvwrite(filename, data); % or writematrix() in newer versions of MATLAB.
or use struct2table and writetable()
t = struct2table(pop);
writetable(t, fileName);

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by