Mr.Kitopa
Mr.Kitopa

Reputation: 51

matlab: how to concatenate strings?

I want to produce multiple movies in matlab like

for i=1:5
   %calculate a movie-array H (gridsize depends on i)
   number=num2str(i);
   movie2avi(H, 'movie_'+number+'.avi');
end

Obviously it doesn't work and I found nothing about multiple movie production in matlab. Any idea how to vary the filename in this command to produce different movie-files instead of overwrite one file?

Upvotes: 1

Views: 6306

Answers (1)

Shai
Shai

Reputation: 114796

In matlab you concatenate strings using strcat and not using + operator!

Try

movie2avi( H, strcat('movie_', number, '.avi') );

Alternatively, you can use [] to concat the literals into a string

movie2avi( H, ['movie_', number, '.avi'] );

Upvotes: 10

Related Questions