-
Notifications
You must be signed in to change notification settings - Fork 2
/
test2c.m
34 lines (22 loc) · 1.09 KB
/
test2c.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
function ObjVal = test2c(BestPosition)
%% BestPositionrite into input .sp file
fidIn=fopen('D:\Users\farshid\Documents\MATLAB\V3.sp','r+');
ach=fread(fidIn);
pchar=char(ach');
%% Its ok
pos=strfind(pchar,'.TE');
fseek(fidIn,pos+6,'bof'); %Yeki Zudtar at Addad, pos mizarim
fprintf(fidIn,'%5f',BestPosition(1));
fclose('all');
%% run hspice
!C:\synopsys\Hspice_D-2010.03-SP1\BIN\hspice.exe -i D:\Users\farshid\Documents\MATLAB\V3.sp -o D:\Users\farshid\Documents\MATLAB\V3
%% read data from .lis file
fidout=fopen('D:\Users\farshid\Documents\MATLAB\V3.lis','r+');
B=fread(fidout);
so = char(B');
pos=strfind(so,'avgpower');
fseek(fidout,pos(1)+11,'bof');
ObjVal=fscanf(fidout,'%f');
fclose('all');
end
% End of function