-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcallfemm.m
45 lines (38 loc) · 871 Bytes
/
callfemm.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% ActiveFEMM (C)2006 David Meeker, [email protected]
function z=callfemm(x)
global ifile ofile HandleToFEMM
if (exist('actxserver'))
z=invoke(HandleToFEMM,'mlab2femm',x);
if (length(z)~=0)
if (z(1)=='e')
error(sprintf('FEMM returns:\n%s',z));
else
z=strrep(z,'I','i');
z=eval(z);
end
end
else
% Form that I'd previously used in Octave:
try
[fid,msg]=fopen(ifile,'wt');
catch
[fid,msg]=fopen(ifile,'w');
end
fprintf(fid,'flput(%s)',x);
fclose(fid);
do
do
try
[fid,msg]=fopen(ofile,'rt');
catch
[fid,msg]=fopen(ofile,'r');
end
if (fid==-1) pause(0.001); end
until (fid~=-1)
u=fgets(fid);
fclose(fid);
until (u~=-1)
pause(0.001);
unlink(ofile);
z=eval(u);
end