How to read a text file, with first column containing letters, and edit the numbers keeping the first column same?

3 ビュー (過去 30 日間)
The image is as shown below. I want to read the numbers only from the text file, and edit them accordingly, keeping the letters column (first column) as same. Thank you.

採用された回答

KSSV
KSSV 2018 年 7 月 2 日
fid = fopen(myfile) ;
S = textscan(fid,'%s %f %f %f') ;
fclose(fid) ;
C1 = S{1} ; % column 1
C2 = S{2} ; % column 2
C3 = S{3} ; % column 3
C4 = S{4} ; % column 4
  2 件のコメント
J Vard
J Vard 2018 年 7 月 2 日
When I am trying to read the letters (C1 in your code above) into other file using 'fprintf' command it showing some error as "Function is not defined for 'cell' inputs". I am guessing that it is because of the single quotations in C1. Is there any way to avoid those quotes so that I can print them in another text file. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by