Writing variables in .csv file and saving it

조회 수: 10 (최근 30일)
Ganesh Kini
Ganesh Kini 2020년 6월 6일
편집: Ameer Hamza 2020년 6월 10일
Hi,
I have a functionality that works perfectly fine. But the output has a set of Numeric value and text strings.
for ex: abc, 1, def,1
def,2, rfg, 1
How can i save the output in a .csv file? do i need to put all my output values of the code to a Matrix then use csvwrite() function?
Please suggest your inputs

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 6월 6일
If you have R2019a or later, you can save the data in a cell array and use writecell()
C = {'abc', 1, 'def' 1; 'def', 2, 'rfg', 1};
writecell(C, 'test.txt')
  댓글 수: 25
Ganesh Kini
Ganesh Kini 2020년 6월 9일
size(backend_full)
Output
ans =
12 7
But when i write the above code for repeated values
fprintf (fid2, '\nEnable,t,');
fprintf (fid2, 'f,', ones(1,size(backend_full)));
Output on the csv file
Enable,t,f,
Please let me know
Ameer Hamza
Ameer Hamza 2020년 6월 10일
편집: Ameer Hamza 2020년 6월 10일
Are all the variables calculated before this line?
vars = {temp, vnw, vpw}
or are they calculated inside for-loop?

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

카테고리

Help CenterFile Exchange에서 Modeling and Prediction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by