clear all
close all
clc


file = fopen('C:\School_work\ESM_4714\node_coords_only.txt')

syms k
% We know that there are 5529 Nodes even though the node number goes up to 6848

for n=1:2:5529*2;
        
        eval(sprintf('N = str2num(fgetl(file));'));
        eval(sprintf('L = str2num(fgetl(file));'));

        x = (n+1)/2;
        node_loc(x,:) = [N(1) L(3) L(1) L(2)]; % Change the order here to X - Y - Z
end      
  

dlmwrite('C:\School_work\ESM_4714\Node_loc_for_ansys_tab.txt',node_loc,'\t')
%csvwrite('C:\School_work\ESM_4714\Node_loc_for_ansys_csv.txt',node_loc)

% This was the header for the file . . . from this we can decipher the note below   
%
% Note . . . nodes are odered according to CS 3 . . . Y - Z - X
%   2420
%          5
% Cylinder
%          1         0         8
% CS1 
%   1.0000000000000000D+000  0.0000000000000000D+000  0.0000000000000000D+000 
%   0.0000000000000000D+000  1.0000000000000000D+000  0.0000000000000000D+000 
%   0.0000000000000000D+000  0.0000000000000000D+000  1.0000000000000000D+000 
%   0.0000000000000000D+000  0.0000000000000000D+000  0.0000000000000000D+000 
%          3         1         8
% CS3 
%   0.0000000000000000D+000  0.0000000000000000D+000  1.0000000000000000D+000 
%   1.0000000000000000D+000  0.0000000000000000D+000  0.0000000000000000D+000 
%   0.0000000000000000D+000  1.0000000000000000D+000  0.0000000000000000D+000 
%   0.0000000000000000D+000  1.3010426069826053D-018  0.0000000000000000D+000 
%          2         0         8
% CS2 
%   1.0000000000000000D+000  0.0000000000000000D+000  0.0000000000000000D+000 
%   0.0000000000000000D+000  1.0000000000000000D+000  0.0000000000000000D+000 
%   0.0000000000000000D+000  0.0000000000000000D+000  1.0000000000000000D+000 
%   0.0000000000000000D+000  0.0000000000000000D+000  0.0000000000000000D+000 
%     -1
%     -1
%   2411