So I'm trying to sort through the two arrays below, and place them in a matrix. The code I'm trying to use is also below. However, the outputs aren't giving me the desired result. I'm trying to take out the (known, known and free, known) for issue 1 and (plane stress) for issue 2, leaving just the numbers in the matrix. Any help on how to correct this would be greatly appreciated.
(Issue 1)
NF_array =
4×1 cell array
{'1, known, known, 0.0, 0.0'}
{'8, known, known, 0.0, 0.0'}
{'4, free, known, 0.0, 0.0' }
{'5, free, known, 0.0, 0.0' }
NF_array = S(NF_2:NL_2);
optf = {'Delimiter',',', 'CollectOutput',true};
fmtf = ['%f%*s',repmat('%f',1,4)];
strf = sprintf('%s\n',NF_array{:});
outf = textscan(strf,fmtf,optf{:});
Nodal_Fixity = outf{1};
Nodal_Fixity = sortrows(Nodal_Fixity)
(Result from code) – Not Correct
Nodal_Fixity =
1 NaN NaN NaN NaN
(Need it to output this)
1 0 0
4 0 0
5 0 0
8 0 0
(Issue 2)
ED_array =
3×1 cell array
{'1, plane stress, 1, 2, 7, 8, 0.1, 29e6, 0.3, 7.3e-6'}
{'2, plane stress, 2, 3, 6, 7, 0.1, 29e6, 0.3, 7.3e-6'}
{'3, plane stress, 3, 4, 5, 6, 0.1, 29e6, 0.3, 7.3e-6'}
ED_array = [{'1, plane stress, 1, 2, 7, 8, 0.1, 29e6, 0.3, 7.3e-6'}, {'2, plane stress, 2, 3, 6, 7, 0.1, 29e6, 0.3, 7.3e-6'}, {'3, plane stress, 3, 4, 5, 6, 0.1, 29e6, 0.3, 7.3e-6'}];
ED_array = S(ED_2:EL_2);
opt = {'Delimiter',',', 'CollectOutput',true};
fmt = ['%f%*s',repmat('%f',1,8)];
str = sprintf('%s\n',ED_array{:});
out = textscan(str,fmt,opt{:});
Element_Data = out{1};
Element_Data = sortrows(Element_Data)
(Result from code)- Not Correct
Element_Data =
1.0e+07 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 2.9000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 2.9000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 2.9000 0.0000 0.0000
(Need it to output this)
1 1 2 7 8 0.1 29e6 0.3 7.3e-6
2 2 3 6 7 0.1 29e6 0.3 7.3e-6
3 3 4 5 6 0.1 29e6 0.3 7.3e-6
Best Answer