Reputation: 23
Can some one explain what this line here does? This is part of an old matlab code I need to reuse for my work
matdir = [params.ariens '-' num2str(dirtimes(ii))];
I'm especially confused about the '-'
part. Thanks a lot in advance.
Upvotes: 0
Views: 84
Reputation: 65460
Single quotes are used to create a string literal so '-'
simply creates a string containing the hyphen character. In MATLAB, [ ... ]
performs horizontal concatenation so the line that you have shown concatenates the string stored in params.ariens
, the character '-'
and the number dirtimes(ii)
converted to a string using num2str
to creat one long string made up of those three strings.
For example:
c = ['abc', '-', 'def']
% abc-def
class(c)
% char
d = ['abc', '-', num2str(10)]
% abc-10
Upvotes: 4