필터 지우기
필터 지우기

Reading the numeric columns from a mixed data type file

조회 수: 3 (최근 30일)
Jay Vaidya
Jay Vaidya 2021년 2월 21일
댓글: Jay Vaidya 2021년 6월 6일
I have a file (attached below) output.mat
I am trying to read the data but everytime I need to manually copy/edit and paste in a new file because the file won't have the same format in every simulation. But one thing is for sure that there will be a numeric data like
time voltage voltage
t1 t2
(3 column data)
.
.
I want to read this data automatically by detecting the headers (time voltage v(t1) and voltage v(t2)). I am not sure how can I read strings in a file. I am currently trying to read individual characters and it takes a lot of efforts still doesn't work. It would be great if you have any suggestions. Thanks in advance.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 2월 22일
Look into readtable. Tables support mixed data types, and will use the headers as the variable names.
You could also use the Import Data tool to interactively set up your import, and then generate a function to reuse. See Import Text Files.
  댓글 수: 1
Jay Vaidya
Jay Vaidya 2021년 6월 6일
Thanks, I needed fair bit of codes to decode the text file but finally I got it working.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by