import *.dat and delete space at last column

조회 수: 6 (최근 30일)
Eduard Sláma
Eduard Sláma 2017년 8월 10일
댓글: Eduard Sláma 2017년 8월 10일
Hi all, my problem is: I want import *.txt (attach file) or *.dat to Matlab *.dat has seven columns and at in last column are numbers and sometimes text (No data) and I need delete this space so output will (Nodata). For export I use this:
number=35;
fid = fopen('zkusebni.txt', 'r' );
h2 = textscan( fid, '%s%s%s%s%s%s%s',number,'CollectOutput', true );
fclose(fid);
C2 = [h2{:}];
C2 = cat(1,h2{:});
When I export this data by my function I get one more row where is in first column is writen (Data) and other columns are empty. So my goal is: I want have same count row like previously without this parasit row (I think I have to change something in h2=textscan()). If is not my text clear look at comments I upload two *.mat what I have from import zkusebni.txt and what I want :) Thank you for your response.
  댓글 수: 4
KSSV
KSSV 2017년 8월 10일
The text file data and want_it.mat looks same.....what you want to edit there?
Eduard Sláma
Eduard Sláma 2017년 8월 10일
Yes this is my goal...but from my code I get have_it.mat. I will have want_it.mat only when I mananually delete space between No data. zkusebni.txt is only sample from my full file. Full file has 621580 rows so I cant delete space between No data manually everywhere :)

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

채택된 답변

AbhimanyuSingh
AbhimanyuSingh 2017년 8월 10일
Please find attached .m file this will help you to solve your problem

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by