I want matlab to read my input data(txt file)
2 views (last 30 days)
Show older comments
this is my input data
I want matlab to read my input data in the beginning of the code.
If i run this code, comes out;
Undefined function or variable 'gettrussdata2D'.
Error in Trussd (line 2)
[nodes,elems,C,A,bcs,loads] = gettrussdata2D(filename);
filename = uigetfile('*.txt','Select the input file');
[nodes,elems,C,A,bcs,loads] = gettrussdata2D(filename);
Nel = size(elems,1);
Nnodes = size(nodes,1);
alldofs = 1:2*nodeNumber;
K = zeros(2*nodeNumber);
u = zeros(2*nodeNumber,1);
f = zeros(2*nodeNumber,1);
dofspec = [];
for ii = 1:size(bcs,1)
thisdof = 2*(bcs(ii,1)-1)+bcs(ii,2);
dofspec = [dofspec thisdof];
u(thisdof) = bcs(ii,3);
end
doffree = alldofs;
doffree(dofspec) = [];
for ii = 1:size(loads,1)
f(2*(loads(ii,1)-1)+loads(ii,2)) = loads(ii,3);
end
for iel = 1:Nel
elnodes = elems(iel,1:2);
nodexy = nodes(elnodes, :);
[Kel] = TrussElement2D(nodexy,C(iel),A(iel));
eldofs = 2*(elnods(1)-1)+1:2*(elnodes(1)-1)+2;
eldofs = [dleofs 2*(elnodes(2)-1)+1:2*(elnodes(2)-1)+2];
K(eldofs,eldofs) = K(eldofs,eldofs) +Kel;
end
u(doffree) = K(doffree,doffree)\(f(doffree)-K(doffree,dofspec)*u(dofspec));
f(dofspec) = K(dofspec,:)*u;
format long
disp(['Displacement vector:']);u
disp(['Forcevector:']);f
2 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!