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일

1 개 추천

try readmatrix() or readtable() instead
Data = readmatrix('100Cr6.csv','NumHeaderlines',1,'DecimalSeparator',',');

댓글 수: 4

Arif Ahmed
Arif Ahmed 2020년 7월 5일
thanks for your reply...
how can i write the value what i got from:
Data = readtable('100Cr6.csv','NumHeaderlines',0,'DecimalSeparator',',');
into another .m file.
thanks in advance
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
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?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Standard File Formats에 대해 자세히 알아보기

질문:

2020년 7월 5일

편집:

Rik
2020년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by