MATLAB: Save ascii from edit uicontrol

save ascii

1). I have m file with 16 edit text using uicontrol like this :
edit16=uicontrol('parent',win1,...
'units','points',...
'position',[320 60 30 15],...
'backgroundcolor',[1 1 1],...
'style','Edit',...
'string','0',...
'fontname','arial',...
'fontsize',10);
Save=uicontrol('parent',win1,...
'units','points',...
'position',[30 20 80 15],...
'style','pushbutton',...
'callback','save',...
'string','Save',...
'fontname','arial',...
'fontsize',10);
and try tosave ascii using this save.m
a=get(edit1,'String');
b=get(edit2,'String');
c=get(edit3,'String');
d=get(edit4,'String');
e=get(edit5,'String');
f=get(edit6,'String');
g=get(edit7,'String');
h=get(edit8,'String');
i=get(edit9,'String');
j=get(edit10,'String');
k=get(edit11,'String');
l=get(edit12,'String');
m=get(edit13,'String');
n=get(edit14,'String');
o=get(edit15,'String');
p=get(edit16,'String');
save red.txt a b c d e f g h i j k l m n o p -ascii
and i cant save it,the error :
Attempt to execute SCRIPT save as a function:
D:\gui\save.m
Error in save (line 37)
save('a', 'b', 'c',
'd','e','f','g','h','i','j','k','l','m','n','o','p', '-ASCII');
Error while evaluating uicontrol Callback
2). And i wonder how to save this ASCII file in any folder,what is the command?

Best Answer

You need to name your save.m something else, something that is not the name of any MATLAB routine that is called upon by the code. You know that the "save" command inside your save.m is intended to refer to the built-in save command, but MATLAB says "Oh, you overrode save.m with your own code, okay, guess I need to call that code, even if it is the same file I'm already executing..."
You can specify a different location to save to:
save('C:\Documents and Settings\Thundercats\red.txt', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', '-ascii')