I have a list of coordinates in a column, ex. ‘43.7N’ and I want the column to just be the numerical value, for example ‘43.7’. How can I eliminate the letter at the end?

1 Commento

Can you attach the list as a .mat file so we can see how the data is structured?

Accedi per commentare.

 Risposta accettata

One approach —
Coords = cell2mat(compose('%.1fN',rand(1,5)*100).') % Create Column
Coords = 5×5 char array
'71.0N' '75.8N' '70.1N' '63.5N' '82.8N'
ReadNrs = cell2mat(textscan(Coords.','%fN')) % Read Column
ReadNrs = 5×1
71.0000 75.8000 70.1000 63.5000 82.8000
whos Coords ReadNrs % Check Variables
Name Size Bytes Class Attributes Coords 5x5 50 char ReadNrs 5x1 40 double
.

Più risposte (0)

Categorie

Prodotti

Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by