come to convert words into cell array
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    shamal
 am 21 Okt. 2024
  
    
    
    
    
    Bearbeitet: Stephen23
      
      
 am 21 Okt. 2024
            g='Eb=3;bb=5;'
i want to create arraycell as similar
S={'Eb',3;'bb',5}
(';' is used to insert a new symbol
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
  Manish
 am 21 Okt. 2024
        
      Bearbeitet: Manish
 am 21 Okt. 2024
  
      Hi, 
I understand that you want to convert the variable‘g’into a cell array‘S’. 
You can achieve this by splitting the string using‘strsplit’ functionand adding the result to the cell array.
Here is the  code implementation:
g = 'Eb=3;bb=5;';
parts = strsplit(g, ';');
S = {};
for i = 1:length(parts)-1
    varValue = strsplit(parts{i}, '=');
    % Add to cell array
    S{i, 1} = varValue{1};     
    S{i, 2} = str2double(varValue{2}); 
end
disp(S);
 Here is the documentation link for ‘strsplit’:
Hope this solves! 
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Cell Arrays 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!


