How to save a filename that is part user input and part text?

1 view (last 30 days)
I'm having trouble figuring out how to save a filename that is part user input and part variable?
For example:
a = input('Please enter a filename: ', 's');
x = 1+1;
y = 2-0;
save(a??, 'x', '-ASCII');
save(a??, 'y', '-ASCII');
Let's say user filename is math
I want to save two different ascii files with a similar name as math, but be able to distinguish the two.
for example, I want to save them as:
mathadd
mathsub
How would I go about doing this with the save function? Is it even possible? Thanks.

Accepted Answer

Honglei Chen
Honglei Chen on 16 Oct 2012
save(sprintf('%sadd',a),'x','-ascii')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!