MATLAB: Writing variable as filename using csvwrite

csvwritefile_writing

Hello Community,
I have a simple problem: I am trying to use the currently selected item from a listbox as the filename in csvwrite:
indexselected = get(handles.listbox1,'Value');
list = get(handles.listbox1,'String');
itemselected = list{indexselected};
filename = intemselected;
csvwrite('filename', A);
this prints literally "filename" as the name of the file instead of the the actual contents of the variable.
Here is the matlab HELP description for csvwrite: csvwrite(filename,M) writes matrix M into filename as comma-separated values. The filename input is a string enclosed in single quotes.
Any suggestions?

Best Answer

token = strtok(itemselected, '.')
csvwrite([token],A)
That works perfectly!