MATLAB: Saving with variable name

MATLABmatlab functionsavetext;

I want to call a function twice. And this function has to save a mat file. So each time it is callled, I want to send a variable name that it must use as the name of the .mat file.
For example:
function mat_fil=(filename)
{ C = cells that i want to save;
save(filename.mat, 'C');
}
end
How do I do this?

Best Answer

function myfun(filename,C)
save([filename '.mat'], 'C');
end