Azzera filtri
Azzera filtri

Convert cell to double

1 visualizzazione (ultimi 30 giorni)
Thomas
Thomas il 14 Lug 2017
Risposto: Rik il 14 Lug 2017
Hello! My question regards converting a cell of sample ID's into a double matrix. The sample ID's are currently in a 77x1 cell that looks like this....
RC448
RC449
RC450
...etc
How can I convert this into a 77x1 double?
I feel like this should be easy and I've seen that other people have asked similar questions, but everything i've tried gives me a char output or replaces the IDs with NaN.
Thanks!

Risposte (1)

Rik
Rik il 14 Lug 2017
You will not be able to convert this to a double array, because a double only holds numbers, and 'RC448' is not a number. Therefore, it returns a NaN output. You can use cellfun to strip the 'RC' and convert the remaining number string to a double. Then use cell2mat to convert to an actual double array.

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by