0

(Edited) We have a string and want it to be repeated, say 5 times, namely from

 str = '%s '; 

to

'%s %s %s %s %s ' 

Question 1: How to specify in the the format argument in textscan() function, to create a new line every 5 strings? I'm looking for something like [repmat('%s', 1, 5) '%*[^\n]'] (this doesn't work).

Question 2: the [data] = textscan(fid, [repmat('%s', 1, 5) '%*[^\n]'], 'Delimiter',{','},'headerLines', 1) currently gives me a 1xn cell - how to convert this into a mxn matrix?;

1
  • 5
    Try repmat(str, 1, n) Commented May 23, 2017 at 17:01

1 Answer 1

1

Use repmat to repeat copies of an array. Pass 1 row and n columns to represent it as an array.

>> str = '%s '; >> repmat(str, 1, 5) ans = %s %s %s %s %s 
Sign up to request clarification or add additional context in comments.

1 Comment

I tried repmat(str, 1, 5) - however it doesn't wrap every 5 strings, please see my edited question. Thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.