I create a code in MATLAB that optimizes an ANSYS study, so i want to check the ANSYS output file and see if the results are acceptable or not.
This code has as imputs parameters that are used by ANSYS to create the model. These parameters change at each iteration, thus at each iteration a different output file is created.
Let's be more specific. Below, there is an example of the output file:
- line 1 blabla
line 2 blabla
. . .
- line 10000 maximum values
- line 10001 values1 2.31 4.56 5.69 8.64 0.25 9.70
- .
- .
- line 35000 maximum values
- line 35001 values2 2.25
- .
- .
- line 70000 total values3 2503.4
All i want to do is to see if the first two values in bold are below the limits of the problem (i.e 9.70<15 and 2.25<7). If they are, store the third value in bold in a matrix. If they are not, go to the next iteration.
I'm pretty new to programming and Matlab instructions are a little confusing.
Any ideas would be welcome!
Thanks in advance!
**EDIT:** That's my entire code so far:
X1=linspace(26,60,3)';
X2=linspace(104,70,3)';
R=linspace(3,10,3)';
vec={X1',X2',R'};
combs=combvec(vec{:})';
seqv=zeros(i,1);
tic
for i=1:length(combs);
fid=fopen('C:\Users\vaioss\Desktop\ergasia ymk\test\aa.txt','w+');
fprintf(fid,'*SET,X1,%7.4f \r\n',combs(i,1));
fprintf(fid,'*SET,X2,%7.4f \r\n',combs(i,2));
fprintf(fid,'*SET,R,%7.4f \r\n',combs(i,3));
fclose(fid);
fid=fopen('C:\Users\...','r+');
fclose(fid);
dos('"C:\Program Files\ANSYS Inc\v150\ANSYS\bin\winx64\ansys150.exe" -p ...');
fid=fopen('C:\Users\...','r');
for j=1:10152;
tline=fgetl(fid);
end
match = textscan(tline, '%s %f %f %f %f %f', '\n')';
seqv(i) = cell2mat(match(6,1));
if seqv(i)>67.2887;
fclose(fid);
continue
end
end
fclose all;
toc