|
%this program is to read the mass matrix and the stiffness matrix
%KAAX the stiffness matrix
%MAAS the mass matrix
% DMIG KAAX 0 6 2 0 273(dof)
% DMIG* KAAX 1(node) 1(x)
% * 1(node) 1(x) 5.087395182D+07
% DMIG* KAAX 1 2
% * 1 1 1.999892380D+07
% * 1 2 5.087395182D+07
% DMIG* KAAX 1 6
% * 1 1-5.470769237D+01
% * 1 2 5.470769237D+01
% * 1 6 2.779150772D+00
% DMIG* KAAX 2 1
% * 1 1-2.933333642D+07
% * 1 2 1.537383915D+06
% * 2 1 1.017479036D+08
% there are 91 node and each node has 3 freedome, so the matrix is a square
% demension 273 matrix
clc
clear all
pretitle='plate_quad';
Nnode=2;
Nfreq=101;
titleB=(['D:\chongxinyuan\Dropbox\matlab\FEM_BEM\',pretitle,'.pch']);
% titleB=(['F:\patranData\',pretitle,'.pch']);
% titleB=(['D:\chongxinyuan\',pretitle,'.f06']);
fid = fopen(titleB, 'r');
dof=273;
Kaax=zeros(dof);
Maax=zeros(dof);
h=1;
column=0;
while ~feof(fid)
tline=fgetl(fid);
if (length(tline)==56) && strcmp(tline(9:12),'KAAX')==1
column=column+1;
elseif length(tline)==56 && (str2num(tline(40))==1 || str2num(tline(40))==2)
lin=(str2num(tline(23:24))-1)*3+ str2num(tline(40));
Kaax(lin,column) =str2num(tline(41:55));
elseif length(tline)==56 && str2num(tline(40))==6
lin=(str2num(tline(23:24))-1)*3+ 3;
Kaax(lin,column) =str2num(tline(41:55));
elseif (length(tline)==56) && strcmp(tline(9:12),'MAAX')==1 % don't mix the mass matrix
break
end
end
fclose(fid);
massok=0;
column2=0;
fid1 = fopen(titleB, 'r');
while ~feof(fid1)
tline=fgetl(fid1);
if length(tline)==72
massok=massok+1; % determine where is the mass matrix
elseif (length(tline)==56) && strcmp(tline(9:12),'MAAX')==1 && massok==2
column2=column2+1;
elseif length(tline)==56 && (str2num(tline(40))==1 || str2num(tline(40))==2) && massok==2
lin=(str2num(tline(23:24))-1)*3+ str2num(tline(40));
Maax(lin,column2) =str2num(tline(41:55));
elseif length(tline)==56 && str2num(tline(40))==6 && massok==2
lin=(str2num(tline(23:24))-1)*3+ 3;
Maax(lin,column2) =str2num(tline(41:55));
end
end
fclose(fid1); |
|