extracting percentages from text

Hi,
I have a .txt data file, like this,
9.26E-02 22% 2.363 ABC
How can I read it into a MATLAB table with four elements?

回答 (1 件)

Dyuman Joshi
Dyuman Joshi 2023 年 11 月 29 日

0 投票

2 件のコメント

Image Analyst
Image Analyst 2023 年 11 月 29 日
@Claire Liu did you try it yet? It should have worked - it's what I would have suggested. If not, attach an actual txt file with the paperclip icon.
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
Peter Perkins
Peter Perkins 2023 年 11 月 29 日
readtable is a start, but likely you will end up with "22%" as text. At that point, you will probably want to do something like t.Var2 = sscanf(t.Var2,"%d%%")/100.

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

製品

リリース

R2019b

質問済み:

2023 年 11 月 29 日

コメント済み:

2023 年 11 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by