out1=sprintf('\n data_convert.m   ver 2.0   March 12, 2010 ');  
out2=sprintf('\n by Tom Irvine  Email: tomirvine@aol.com ');
out3=sprintf('\n This program converts Matlab data to ASCII text data. ');
disp(out1);
disp(out2);
disp(out3);
%
clear av;
out4=sprintf('\n Enter the output filename: ');
disp(out4);
output_filename = input(' ','s');
%
out5=sprintf('\n Enter the Matlab data format: ');
out6=sprintf('  1=Data is in a single array ');
out7=sprintf('  2=Data is in multiple vectors ');
disp(out5);
disp(out6);
disp(out7);
%
idf=input(' ');
disp(' ');
%
if(idf==1)
%
    av = double(input(' Enter the Matlab vector or array name:  '));
    [m,n] = size(av);
%
else
    disp(' Enter the number of columns ');
    nc=input(' ');
    disp(' ');
    for(i=1:nc)
        out1=sprintf(' Enter vector name %d',i);
        disp(out1);
        name=input(' ');
        p=length(name);
        for(j=1:p)
            av(i,j)=double(name(j))';
        end
    end
    av=av';
    [m,n] = size(av);   
%        
end
%
out4 = sprintf('\n\n rows = %d   columns = %d \n',m,n);
disp(out4)
%
%
disp(' ');
disp(' Select precision: ');
disp(' 1=single  2=double ');
ip=input(' ');
%
if(ip==1)
    save(output_filename,'av','-ASCII')  
else
    save(output_filename,'av','-ASCII','-double')
end
%
disp('  Data save complete.')
%
%  old method
%
%fid = fopen(output_filename,'w');
%
%for i=1:m
%    for j=1:n
%        fprintf(fid,'%14.7e \t',av(i,j));
%    end
%    fprintf(fid,' \n ');
%end
%
% fclose(fid);