-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpFinder.m
More file actions
38 lines (34 loc) · 1.01 KB
/
Copy pathpFinder.m
File metadata and controls
38 lines (34 loc) · 1.01 KB
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
function deltaNow=pFinder(pReq,pList,indicator,alphaIn)
deltaList = 0:0.01:pi/2;
alphaIn = rad2deg(alphaIn);
if (alphaIn > 68 && alphaIn < 110) || (alphaIn > 250 && alphaIn < 290)
indicator = ~indicator;
end
if indicator == 0
idmax = pList >= 0;
pList = pList(idmax);
deltaList = deltaList(idmax);
[~,imax] = max(pList);
pList = pList(1:imax);
deltaList = deltaList(1:imax);
[~,index] = sort(pList);
% idpos = pList >=0;
% idpos = idpos(1:imax);
% pList = pList(idpos);
% deltaList = deltaList(idpos);
% [~,index] = sort(pList(idpos));
elseif indicator == 1
idmin = pList < 0;
pList = pList(idmin);
deltaList = deltaList(idmin);
[~,imin] = min(pList);
pList = pList(1:imin);
deltaList = deltaList(1:imin);
[~,index] = sort(pList);
end
if pReq >= max(pList)
pReq = max(pList);
elseif pReq <= min(pList)
pReq = min(pList);
end
deltaNow =interp1(pList(index),deltaList(index),pReq,'linear','extrap');