% This function Recieves the required data and modifies the data files

function modifydat4col(len,n,r,E,typ)

I=pi*r.^4/4;
A=pi*r.^2;
% Writing the data for nodes
h=len/n;        % element size or mesh size
y=0;
x=0:h:len;
fid=fopen('nodes.dat','w');
for i=1:n+1
    fprintf(fid,'%d\t%e\t%e\n',i,x(i),y);
end
fclose(fid);
% writing the data for elements
% in the order Sl.No nodeid1 nodeid2 E density A I ymax
fid=fopen('elements.dat','w');
for i=1:n
    fprintf(fid,'%d\t%d\t%d\t%e\t%e\t%e\n',i,i,i+1,E,A(i),I(i));
end
fclose(fid);
%Writing to the file in the order Sl.No. node id, dof, dislacement value
fid=fopen('dispbc.dat','w'); 
switch typ
    case 1               
        % fixed-free
        for i=1:3
            fprintf(fid,'%d\t%d\t%d\t%e\n',i,1,i,0);
        end
        %
    case 2
        % pinned pinned
        for i=1:2
            fprintf(fid,'%d\t%d\t%d\t%e\n',i,1,i,0);
        end
        for i=1:2
            fprintf(fid,'%d\t%d\t%d\t%e\n',i+2,n+1,i,0);
        end
end
fclose(fid);
