-3

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

Adupa Vasista
  • 71
  • 1
  • 12

2 Answers2

0

Got it

dotspace = '. '
for k = 1:length(txt)
    match{k} = [num2str(k,'%d') dotspace];
end
max
  • 3,915
  • 2
  • 9
  • 25
Adupa Vasista
  • 71
  • 1
  • 12
0

Just use strings.

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

Now you can use erase just like before.

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58