Writing variable as filename using csvwrite

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?

 Réponse acceptée

B_Richardson
B_Richardson le 12 Juil 2011
token = strtok(itemselected, '.')
csvwrite([token],A)
That works perfectly!

Plus de réponses (1)

Nathan Greco
Nathan Greco le 12 Juil 2011
Try writing:
csvwrite(filename,A); %without quotes

4 commentaires

B_Richardson
B_Richardson le 12 Juil 2011
Yes, I tried that but it simply doesnt work without the quotes. I guess because the function specifies that the filename be enclosed in quotes:
"The filename input is a string enclosed in single quotes."
B_Richardson
B_Richardson le 12 Juil 2011
And just to make sure I checked the value within itemselected
itemselected =
RHA_RL_INC_0003_v2.59806163.avi
Oleg Komarov
Oleg Komarov le 12 Juil 2011
filename = 'RHA_RL_INC_0003_v2.59806163.avi';
csvwrite(filename,10)
will create an *.avi-names file. Check it out and replace .avi with csv.
Walter Roberson
Walter Roberson le 12 Juil 2011
Please cross-check
class(itemselected)

Connectez-vous pour commenter.

Catégories

En savoir plus sur App Building dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by