How to select non-string variables convertvars( ) argument?
    6 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
I want to convert non-string variables to string using convertvars. I can do convertvars(T, @isnumeric, 'string') and convertvars(T, @iscell, 'string'). When I want to convert all variables to string, that approach would be cumbersome. I have tried ~@isstring. That is of course a rediculous and wrong idea. Is there a way to select non-string variables from a table?
c = {1,2,3;'a','b','c'; "d", "e", "f"}'
t = cell2table(c)
convertvars(t, @isnumeric, 'string') % convert one column at a time
convertvars(t, 1:width(t), 'string') % works but I like to see a better solution
2 Kommentare
  Mathieu NOE
      
 am 31 Jan. 2024
				why is 
convertvars(t, 1:width(t), 'string') % works but I like to see a better solution
not a good solution in your eyes ? 
Akzeptierte Antwort
  Voss
      
      
 am 31 Jan. 2024
        c = {1,2,3;'a','b','c'; "d", "e", "f"}'
t = cell2table(c)
convertvars(t, @(x)~isstring(x), 'string')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!