question regarding renaming a string

1 view (last 30 days)
kambiz
kambiz on 8 Jul 2012
Dear all,
I am sort of new to matlab and spm and I have a question that I am sure is simple for most of you. I have a string which is named "2.40-resting-s005" and I want to rename it in way that I can compare it with another string using strcmp. However, I need the rename file to be started with letter A following by 4 digits following by dot and finally following with 2 digits like "A0002.40". For doing this I used the following command:
sprintf('A%04d.%d', test)
in which test='2.40-resting-s005'
, but I don't get the output in the format that I want('A0002.40'). Could you please help me to sort out this problem.
Best Kami

Answers (1)

Walter Roberson
Walter Roberson on 8 Jul 2012
sprintf('A%04d.%d', sscanf('%f',test))

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!