How can I use matlab to write data from a textfile and into an Excel sheet?

조회 수: 7 (최근 30일)
Stian
Stian 2014년 5월 13일
편집: Stian 2014년 5월 19일
My problem is that I got my data from laboratory testing in text files (.txt), and I can't copy them to an Excel sheet (3 columns and 5000+ rows). The text files got information like this:
Specimen identifier Test1 $
Time, Standard force, Standard travel
1.767510000000e+001,-4.922511577606e-001, 0.000000000000e+000
1.779509999732e+001,-4.709413945675e-001, 0.000000000000e+000
1.783509999642e+001,-4.614703953266e-001, 0.000000000000e+000
1.823510000238e+001,-1.105498909950e+000,-4.774307832122e-003
I am able to read the text file and plot it, but when I want to write it to Excel to have them in different columns, it gets harder to figure out how to do it. I got like 5000 rows, so to do it manually isn't an option :)
Anyone got an idea on how to extract it from the text file (.txt) and over to an Excel sheet, with the help of MATLAB?
Thankful for every answer I may get :)
-Stian

채택된 답변

Sara
Sara 2014년 5월 13일
Once you have the data in matlab, use xlswrite. If you have 3 cols and n rows, where n can change:
xlswrite('filename.xlsx',your_array,['A1:C',num2str(n)])
  댓글 수: 1
Stian
Stian 2014년 5월 19일
편집: Stian 2014년 5월 19일
Thank you.
I ended up with this setup:
filename = 'Test1.xlsx';
Row = 5018; %Chosen timevalue at start of last cycle
T1 = [csvread('Test1.txt', Row, 0)]
xlswrite(filename,T1)

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 5월 13일
Use xlswrite

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by