-
Notifications
You must be signed in to change notification settings - Fork 3
/
findsing.m
54 lines (48 loc) · 1.68 KB
/
findsing.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
46
47
48
49
50
51
52
53
54
function [averagevoltage]=findsing(alpha,lowdelta,topdelta,lowvoltage,topvoltage,X,Y,Z)
averagevoltage=zeros(1,length(alpha));
indexalpha= zeros(1,length(alpha));
indexlowdelta= zeros(1,length(alpha));
indextopdelta= zeros(1,length(alpha));
lowydelta= zeros(1,length(alpha));
topydelta= zeros(1,length(alpha));
topzvoltage=zeros(1,length(alpha));
lowzvoltage=zeros(1,length(alpha));
diffaprroxreal=zeros(length(alpha),2);
for i=1:length(alpha)
difference=0.05;
count=1;
while(X(1,count)<alpha(i)+0.01)
if(difference>abs(alpha(i)-X(1,count)))
difference=abs(alpha(i)-X(1,count));
indexalpha(i)=count;
end
count=count+1;
end
difference=0.05;
count=1;
while(Y(count,1)<lowdelta(i)+0.01)
if(difference>abs(abs(lowdelta(i))-abs(Y(count,1))))
difference>abs(abs(lowdelta(i))-abs(Y(count,1)));
indexlowdelta(i)=count;
lowydelta(i)=Y(count,1);
end
count=count+1;
end
difference=0.05;
count=1;
while(Y(count,1)<topdelta(i)+0.01)
if(difference>abs(abs(topdelta(i))-abs(Y(count,1))))
difference>abs(abs(topdelta(i))-abs(Y(count,1)));
indextopdelta(i)=count;
topydelta(i)=Y(count,1);
end
count=count+1;
end
topzvoltage(i)=Z(indextopdelta(i),indexalpha(i));
lowzvoltage(i)=Z(indexlowdelta(i),indexalpha(i));
diffapproxreal(i,1)=lowzvoltage(i)-lowvoltage(i);
diffapproxreal(i,2)=topvoltage(i)-topzvoltage(i);
averagevoltage(i)=(diffapproxreal(i,2)*lowzvoltage(i) ...
+diffapproxreal(i,1)* topzvoltage(i)) ...
/(diffapproxreal(i,1)+diffapproxreal(i,2))
end