Converting raw gas chromatograph data to a matrix

조회 수: 3 (최근 30일)
Nicholas  Frank
Nicholas Frank 2015년 5월 18일
댓글: Star Strider 2015년 5월 19일
My gas chromatograph has the ability to output .csv files and I can open them in excel. Excel has the ability to use the text to columns function and remove the comma, allowing the csv data to be separated into two columns. However, I would much rather do this in MATLAB and have everything be automated. But when I try and use the csvread function there is an error because when importing the data from excel to MATLAB, there is now quotation marks surrounding my csv's.
For example, my first value which I need separated is: "0.00333333333333333,869721.594606312"
I know there is a simple solution either using strrep or csvread, but I can't seem to get it right. Any help is appreciated, thank you.
Thanks!

채택된 답변

Star Strider
Star Strider 2015년 5월 18일
If your version of Excel can read it, then the MATLAB xlsread function should be able to as well.
  댓글 수: 7
Nicholas  Frank
Nicholas Frank 2015년 5월 19일
hHanks so much! This works :).
Star Strider
Star Strider 2015년 5월 19일
My pleasure!

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 18일
fid = fopen('SIGNAL1.CSV');
C = textscan(fid,'"%f,%f"', 'CollectOutput', 1);
fclose(fid);
YourData = C{1};
  댓글 수: 1
Star Strider
Star Strider 2015년 5월 19일
Brilliant!
I wish I’d thought to include the double quotes and the comma in the format descriptor when I experimented with textscan. That eliminates both as problems, with no further data manipulation needed. Something to remember.

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

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by