Search code examples
stringmatlabcell-arrayerase

creating this specific cell array in MATLAB


I want to create this particular cell array. I don't want to do it manually,

a = {'1. ','2. ','3. ','4. ', ........upto length(txt)}

I thought of create initially numbers with 1:length(txt) and append it to '.' to create cell array a, But I am facing many errors there.

So that I can use erase function with argument as a

erase(txt,a), where txt contains these numbers at the starting as an example it goes as

1. xxxxxxxxxxxxxxxxxxxxxxxxxxx

2. yyyyyyyyyyyyyyyyyyyyyyyyyyy

3. zzzzzzzzzzzzzzzzzzzzzzzzzzz

So on......

So the output when I run erase will be like

xxxxxxxxxxxxxxxxxxxxxxxxxxx

yyyyyyyyyyyyyyyyyyyyyyyyyyy

zzzzzzzzzzzzzzzzzzzzzzzzzzz


Solution

  • Just use strings.

    match = (1:length(txt)) + ". ";
    

    Now you can use erase just like before.