php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 252|回复: 0

位移因子计算

[复制链接]

2615

主题

2622

帖子

9281

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
6544
贡献
0
注册时间
2021-4-14
最后登录
2024-4-19
在线时间
665 小时
QQ
发表于 2022-11-26 06:46:26 | 显示全部楼层 |阅读模式
[mw_shl_code=applescript,true] function distance=shift(a,b)
global t0 t2 y0 y2 x1;
y0=b(1,2);
y2=a(end,2);

if y0<y2
    disp('error');
    distance=0;
    return;
end
t0=find_x(y0,a);
t2=find_x(y2,b);
x1=find_x(y0,b);

t1=a(end,1);
t_mid=((t0+t1)/2);

t_top=t0;
t_bot=t1;
iteration=1;

while 1
    iteration=iteration+1;
    y1=find_y(t_mid,a);
    x0=find_x(y1,b);
    distance=t_mid-x0;
    ind=(b(:,2)>y1);
    range_b=b(ind,;
    ind=(a(:,2)>y1)&(a(:,2)<y0);
    range_a=[[t0,y0];a(ind,];
    area_t=integral(range_a,range_b,distance,t_mid,y1,1);
   
    ind=(b(:,2)<y1)&(b(:,2)>=y2);
    range_b=[b(ind,;[find_x(y2,b),y2]];
    ind=(a(:,2)<y1);
    range_a=a(ind,;
    area_b=integral(range_a,range_b,distance,t_mid,y1,2);
    fprintf('top=%f, bottom=%f\n',area_t,area_b);
   
    if (abs(area_t-area_b)>1e1)
        if area_t<area_b
            t_bot=t_mid;
            t_mid=(t_top+t_mid)/2;
        else
            t_top=t_mid;
            t_mid=(t_bot+t_mid)/2;
        end
        if (iteration>20)
            disp('iteration hits max times');
            break
        end
        if ((iteration>2)&&(abs(distance_t-distance)<1e-4))
            break;
        end
    else
        break
    end
    distance_t=distance;
end
disp('iteration');
disp(iteration);[/mw_shl_code]





上一篇:QuartusII一键清理编译过程文件
下一篇:每隔2周休息1天工厂日历生成
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )51LA统计

GMT+8, 2024-4-20 00:19 , Processed in 0.175342 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表