MATLAB concatenate string variables

MATLAB concatenate string variables

What version of MATLAB are you using? What is the error? The first input to strjoin needs to be a cell array. Try strjoin({rm},a).

Also, before 17a, do:

a = strcat(file, num2str(i),.mat)

In >=17a do:

a = file + i + .mat;

Here is a performance comparison:

function profFunc

    tic;
    for i = 1:1E5
        a = strcat(file, num2str(i),.mat);
    end
    toc;

    tic;
    for i = 1:1E5
        a = file + i + .mat;
    end
    toc;
end

>> profFunc
Elapsed time is 6.623145 seconds.
Elapsed time is 0.179527 seconds.

MATLAB concatenate string variables

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *