How to remove empty spaces in between text in a cell array?

3 visualizaciones (últimos 30 días)
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'};

Respuesta aceptada

Stephen23
Stephen23 el 22 de Feb. de 2016
Editada: Stephen23 el 22 de Feb. de 2016
Just use strrep:
>> 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
Karthick Jonagadla
Karthick Jonagadla el 22 de Feb. de 2016
Solution works. Thanks!
Stephen23
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by