Finding a series of numbers in a cell
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Patrick
el 15 de Ag. de 2017
Comentada: Patrick
el 15 de Ag. de 2017
Good day,
I have the following cell called "c"
c = {'Conc_510_Y2_Asym_27730_AuditoryOddball'
'Conc_510_Y2_Asym_27730_GoNoGo'
'Conc_510_Y2_Baseline_27855_AuditoryOddball'
'Conc_510_Y2_Baseline_27855_GoNoGo'
'Conc_510_Y2_Mid_27632_AuditoryOddball'
'Conc_510_Y2_Mid_27632_GoNoGo'
'27135_AuditoryOddball'
'27260_AuditoryOddball'
'27325_AuditoryOddball'
'27459_AuditoryOddball'
'27430_AuditoryOddball'
'27430_GoNoGo'
'TS#27371'
'TS#27430'
'TS#27487'
'TS#27636'
'TS#27708'
'TS#27391'
'TS#27419'
'TS#27623'
'TS#27647'
'TS#25658'
'TS#25707'
'TS#25897'
'TS#27059'
'TS#27143'
'TS#27589'
'TS#27631'
'TS#27762'
'TS#27797'
'TS#25762'
'TS#27204'
'TS#27253'
'TS#27274'
'25874'
'TS#27075'
'TS#27131'
'TS#27167'
'TS#27345'
'TS#27489'
'TS#27516'
'TS#27518'
'TS#27732'
'27090_AuditoryOddball'
'27268_AuditoryOddball'
'Other - TS#27505'
'Other - TS#27775 - Other'
'Other -TS#27423'
'TS#27021 - Baseline'
'TS#27091'
'TS#27315 -Asym'
'TS#27475'
'TS#27484'
'TS#27642'
'TS#27665'
'TS#27759'
'TS#25672'
'TS#25843'
'TS#27156'
'TS#27279'
'TS#27314'
'TS#27404'
'TS#27407'
'TS#27617'
'TS#27688'
'TS#27856'
'27558_AuditoryOddball'
'27702_AuditoryOddball'
'27714_AuditoryOddball'
'27745_AuditoryOddball'
'27798_AuditoryOddball'
'Other Files'
'27433_AuditoryOddball'
'27547_AuditoryOddball'
'27588_AuditoryOddball'
'27474_AuditoryOddball'
'27523_AuditoryOddball'
'27705_AuditoryOddball'
'Other Files'
'TS#27076'
'TS#27138'
'TS#27275'
'TS#27537'
'27336_AuditoryOddball'
'27533_AuditoryOddball'
'27614_AuditoryOddball'
'27669_AuditoryOddball'
'27862_AuditoryOddball'
'Other Files'
'27335_AuditoryOddball'
'27445_AuditoryOddball'
'27467_AuditoryOddbal'
'27683_AuditoryOdddball'
'27755_AuditoryOddball'}
I am trying to extract the series of 5 numbers from the cell and store it into an array. Such that the results from the first 5 results would be
[27730;
27730;
27855;
27855;
27632;]
I know that I can use @cellfun to scan if there is a specific number within a cell
find(cell2mat(c)==2)
However, this method won't work here. I would appreciate any guidance/help.
Thanks,
2 comentarios
Image Analyst
el 15 de Ag. de 2017
Whatever you posted on some third party website, paste here instead.
To get the results from the k'th cell of the cell array, use braces:
cellContents = c{k}; % Extract k'th cell into double array.
Respuesta aceptada
Guillaume
el 15 de Ag. de 2017
Editada: Guillaume
el 15 de Ag. de 2017
It's not clear exactly what pattern you're looking for. The following will work for your first five numbers:
str2double(regexp(yourcellarray, '\d+(?=[^0-9]*$)', 'match', 'once'))
but so would many other patterns which would produce different results for the rest of the array.
Note: rather than using an external service, paste an excerpt of your cell array into your question.
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays 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!