Remove Whitespace & Text From Cell

2 visualizaciones (últimos 30 días)
Cesar Cabrera
Cesar Cabrera el 31 de En. de 2023
Comentada: Stephen23 el 31 de En. de 2023
If I have a cell like
[0.078 ms]
How can I remove both the whitespace and 'ms' to yield the result
[0.078]
Thanks,
  1 comentario
Stephen23
Stephen23 el 31 de En. de 2023
@Cesar Cabrera: please upload a sample data file by clicking the paperclip button.

Iniciar sesión para comentar.

Respuestas (2)

Kunal Kandhari
Kunal Kandhari el 31 de En. de 2023
Hi,
You can make use of strrep: Find and replace substrings function
  3 comentarios
Kunal Kandhari
Kunal Kandhari el 31 de En. de 2023
Hi Cesar,
You you please explain it is several thousand cell array or array of cells?
So that I can help you with that..
Can you write a dummy variable here?
Cesar Cabrera
Cesar Cabrera el 31 de En. de 2023
.txt file
|0.56 ms|
|0.86 ms|
|0.91 ms|
|0.25 ms|
T= readtable(example.txt)
I want to parse the data into a table from a .txt file like
0.56
0.86
0.91
0.25

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 31 de En. de 2023
See https://www.mathworks.com/help/matlab/ref/matlab.io.text.delimitedtextimportoptions.setvaropts.html#d124e755396 for the import options to ignore particular prefixes or suffixes. You would detectImportOptions and setvaropts and then pass the resulting options to readtable

Categorías

Más información sobre String Parsing en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by