problem with csv to .m conversion

1 回表示 (過去 30 日間)
Arif Ahmed
Arif Ahmed 2020 年 7 月 5 日
編集済み: Rik 2020 年 7 月 6 日
Hello,
I am having problem reading in this file to matlab.
Data = fileread('100Cr6.csv');
Data = strrep(Data, ',', '.');
FID = fopen('kf100CR6.m', 'w');
fwrite(FID, Data, 'char');
fclose(FID);
i use the following code but it does not generate the data what i want?
i want every data in double notation (like 1231.2354) format. so that i can use these as columns or rows of matrix.
Does anyone have a solution to this?
Many thanks.

回答 (1 件)

jonas
jonas 2020 年 7 月 5 日
try readmatrix() or readtable() instead
Data = readmatrix('100Cr6.csv','NumHeaderlines',1,'DecimalSeparator',',');
  4 件のコメント
Arif Ahmed
Arif Ahmed 2020 年 7 月 5 日
編集済み: Rik 2020 年 7 月 6 日
Data = readtable('100Cr6.csv','NumHeaderlines',0,'DecimalSeparator',',');
% FID = fopen('kf100CR6.m', 'w');
fid = fopen('kf100CR6.m', 'wt'); % Open m-file for writing as a text file.
if fid ~= -1
[rows, columns] = size(Data)
fprintf(fid, '', Data)
fclose(fid)
end
how can i write the data from .csv to .m file?
jonas
jonas 2020 年 7 月 6 日
What is the problem?

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by