How to strrep only certain strings

5 ビュー (過去 30 日間)
Michael Boyle
Michael Boyle 2021 年 10 月 18 日
編集済み: Bruno Luong 2021 年 10 月 18 日
I have a cell array with values like e-.00085 and 8.5e-4. I am trying to replace the 'e' with nothing '' in the value with the leading e, while leaving the scientific notation e alone.
x = ['e-.00085';'8.5e-4'];
strrep(x,'e','');
desired_final_ans = ['-.00085';'8.5e-4'];
Is there a way to determine in an if statement whether the cell begins with an 'e'?
  2 件のコメント
Bruno Luong
Bruno Luong 2021 年 10 月 18 日
編集済み: Bruno Luong 2021 年 10 月 18 日
The questions are not the same strickly speaking.

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

採用された回答

Bruno Luong
Bruno Luong 2021 年 10 月 18 日
x = {'e-.00085';'8.5e-4'}
x = 2×1 cell array
{'e-.00085'} {'8.5e-4' }
regexprep(x, '^e', '')
ans = 2×1 cell array
{'-.00085'} {'8.5e-4' }

その他の回答 (1 件)

KSSV
KSSV 2021 年 10 月 18 日
x = {'e-.00085';'8.5e-4'};
y = strrep(x,'e','')
y = 2×1 cell array
{'-.00085'} {'8.5-4' }

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by