フィルターのクリア

Import an oddly shaped txt file

1 回表示 (過去 30 日間)
ayat
ayat 2016 年 3 月 29 日
回答済み: KSSV 2016 年 3 月 29 日
I have a txt file that is with a weird shape as you can see in the attached. When I use the import feature in matlab and choose nemeric matrix, the imported matrix looks like it should (each value allocated to the correct number on the second row). I don`t know how to replicate that in code. On a side note, is it possible to replace the "," with "." and then import?

回答 (1 件)

KSSV
KSSV 2016 年 3 月 29 日
clc; clear all ;
file = 'B00001.txt' ;
fid = fopen(file,'r') ;
S=textscan(fid,'%s','delimiter','\n');
fclose(fid) ;
S = S{1} ;
All the file contents will be saved in cell S. You can do what ever you want from S.
Note that there are many other ways to read a file.

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by