How to remove empty spaces in between text in a cell array?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Karthick Jonagadla
el 22 de Feb. de 2016
Comentada: Stephen23
el 22 de Feb. de 2016
I wish to remove the empty spaces in between text in a cell array. Any help would be appreciated . Actual:
Data={'Symbol','Date','Expiry','Open','High','Low','Close','LTP','Settle Price','No. of contracts','Turnover in Lacs','Open Int','Change in OI','Underlying Value '};
Desired:
Data={'Symbol','Date','Expiry','Open','High','Low','Close','LTP','SettlePrice','No.ofcontracts','TurnoverinLacs','OpenInt','ChangeinOI','UnderlyingValue'};
0 comentarios
Respuesta aceptada
Stephen23
el 22 de Feb. de 2016
Editada: Stephen23
el 22 de Feb. de 2016
>> Data={'Symbol','Date','Expiry','Open','High','Low','Close','LTP','Settle Price','No. of contracts','Turnover in Lacs', 'Open Int','Change in OI','Underlying Value '};
>> strrep(Data,' ','')
ans =
'Symbol' 'Date' 'Expiry' 'Open' 'High' 'Low' 'Close' 'LTP' 'SettlePrice' 'No.ofcontracts' 'TurnoverinLacs' 'OpenInt' 'ChangeinOI' 'UnderlyingValue'
If you are planning on using these as fieldnames, then you might like to consider using genvarname instead:
>> genvarname(Data)
ans =
'Symbol' 'Date' 'Expiry' 'Open' 'High' 'Low' 'Close' 'LTP' 'SettlePrice' 'No0x2EOfContracts' 'TurnoverInLacs' 'OpenInt' 'ChangeInOI' 'UnderlyingValue'
2 comentarios
Stephen23
el 22 de Feb. de 2016
My pleasure! On this forum it is considered polite to accept the answer that best resolves your question.
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!