MATLAB: Insert elements of array in a string one by one

for loopMATLABstringurlvariable

i have a string containing url ' 098909 —'
the digits in the bold are to be changed at every iteration of the for loop and the new element of an array are to be inserted. But MATLAB does not consider a variable inside a string.
How can i solve this problem?
Thanks in advance.

Best Answer

  • Depending on the inputs something like this might help:
    for k = 98900:98999
    S = sprintf(['', ...
    '/ %06d ---'], k)
    C = {'098909', '098910', '098911'};
    for k = 1:3
    S = sprintf(['', ...
    '/ %s ---'], C{k})
    If you provide the definition for the changing part of the string, a matching answer is more likely.