Reputation: 77
This is my name now:
fn_la= ' myfile.env'
In this name I want to include a variable called date= 20170805.
So the name is myfile20170805.env.
Some one know how to do that in matlab?
Upvotes: 1
Views: 53
Reputation: 313
Here is the code:
fn_la= ' myfile.env'
date= 20170805
C = strsplit(fn_la,'.')
name=sprintf('%s%d.%s.',C{1},date,C{2})
You might want to use strtrim
to remove the whitespace:
name=strtrim(name)
Upvotes: 1