problem with csv to .m conversion
显示 更早的评论
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
2020-7-5
try readmatrix() or readtable() instead
Data = readmatrix('100Cr6.csv','NumHeaderlines',1,'DecimalSeparator',',');
4 个评论
Arif Ahmed
2020-7-5
Image Analyst
2020-7-5
Use fprintf()
fid = fopen('Arif Ahmed.m', 'wt'); % Open m-file for writing as a text file.
if fid ~= -1
[rows, columns] = size(Data)
fprintf(fid, '....whatever...', Data...........)
fclose(fid)
end
Using fprintf() you can make the lines of text in the m file look however you want them to.
Arif Ahmed
2020-7-5
编辑:Rik
2020-7-6
jonas
2020-7-6
What is the problem?
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!