24小时热门版块排行榜    

查看: 2405  |  回复: 0

mayaya26

木虫 (小有名气)

[求助] 请教大家一个MATLAB求解四元一次方程组的问题

编程中里面存在方程组fun_2,方程组中的未知量为 x y theta theta1 ,我尝试用简单的牛顿法求解,好像不行,求各位高手相助。谢谢

程序如下:
function f=fun_2(x)
d=0.4;epsilong=9;
xt=-0.5;xr1=0.5;L=5;
syms x y theta theta1

phi=asin(sin(theta)./sqrt(epsilong));
phi1=asin(sin(theta1)./sqrt(epsilong));

Lt=d/cos(phi);
L1=d/cos(phi1);
Ltt=(y-d)/cos(theta);
L11=(y-d)/cos(theta1);

f1=(x-xt)^2+y^2-(Lt^2+Ltt^2 +2*Lt*Ltt*cos(theta - phi));
f2=(x-xr1)^2+y^2-(L1^2+L11^2 +2*L1*L11*cos(theta1 - phi1));
f3=L-sqrt(epsilong)*Lt+Ltt+sqrt(epsilong)*L1+L11;

f=[f1 f2 f3];

end

function df=dfun_2(x)
syms x y theta theta1
f=fun_2(x);
df=[diff(f,'x');diff(f,'y');diff(f,'theta');diff(f,'theta1')];
df=conj(df');
end

function x=newton_2(x0,eps,N)
con=0;  
% syms x y theta theta1
%其中x0为迭代初值eps为精度要求N为最大迭代步数con用来记录结果是否收敛 for i=1:N;
x0=[0 1 0.5 0.4];eps=1.0e-3;N=10;
for i=1:N;
    f=subs(fun_1(x0),{'x' 'y' 'theta' 'theta1'},{x0(1) x0(2) x0(3) x0(4)});
    df=subs(dfun_1(x0),{'x' 'y' 'theta' 'theta1'},{x0(1) x0(2) x0(3) x0(4)});
    x=x0-f/df;
    for j=1:length(x0)
        il(i,j)=x(j);
    end
    if norm(x-x0)<eps
        con=1;
        break;
    end
    x0=x;
end

运行结果: newton_2
Error using mupadmex
Error in MuPAD command: Out of memory.

Error in sym/privBinaryOp (line 1506)
            Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});

Error in sym/mrdivide (line 237)
        X = privBinaryOp(A, B, 'symobj::mrdivide');

Error in newton_2 (line 9)
    x=x0-f/df;

是哪里出错了?大神们帮帮忙,比较急
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 mayaya26 的主题更新
信息提示
请填处理意见