Combine multiple lines into one line in matlab

I have an A variable containing several arrays of strings as follows:

'0'    '->'    '2'      '1.000000'    '1.000200'    'A-MPDU'     '1.000000'
'0'    'NO'    'NaN'    '1.000270'    '1.000570'    'BACKOFF'    'NaN'     

I want to make these lines in one lowercase form as follows:

'0 -> 2 1.000000 1.000200 A-MPDU 1.000000'
'0 NO NaN 1.000270 1.000570 BACKOFF NaN'   

How to implement this with Matlab?

+4
source share
3 answers

Presumably Athis is an array of cells, so you can convert a single line from it to an array of characters using

char(cellfun(@(x)[x ' ']',C(1,:),'UniformOutput',false))'

, cellfun () . (.. "0" "0" ), , . , - , , .

>> char(cellfun(@(x)[x ' ']',C(1,:),'UniformOutput',false))'

   ans =
         0 -> 2 1.000000 1.000200 A-MPDU 1.000000 

>> char(cellfun(@(x)[x ' ']',C(2,:),'UniformOutput',false))'

   ans =
         0 NO NaN 1.000270 1.000570 BACKOFF NaN 

, !

+4

1:

, strcat

Example:

str = strcat('Good', 'morning')

str =

Goodmorning

:

, - : '0 ' '-> ' '2 ', .

:

a='aaaa';
b='bb';
c=sprintf('%s %s',a,b); 
+4

, A, . , .

A={'0'    '->'    '2'      '1.000000'    '1.000200'    'A-MPDU'     '1.000000';
   '0'    'NO'    'NaN'    '1.000270'    '1.000570'    'BACKOFF'    'NaN'}

concatenatedCell= {[A{1,:}];[A{2,:}]}

:

'0->21.0000001.000200A-MPDU1.000000'
'0NONaN1.0002701.000570BACKOFFNaN'

You will see that there are no spaces here (compared to your output). They will not enter your output if: 1. they are in your input line or 2. you insert it into the line when concatenating (a little complicated).

+1
source

All Articles