Problem with Argument and fsolve

Hi everyone, I am trying to solve:
S= (50625*(arg(x*i + y - 1393 - 746*i) - 3560289735917593/36028797018963968)^2)/pi^2 + ((x + (y - 987)^2 - 24025)^(1/2)/2 - 8643/20)^2 + (3240000*(arg(x*i + y - 259 - 1571*i) + 8955599335723659/288230376151711744)^2)/(169*pi^2) + (90000*(arg(x*i + y - 375 - 629*i) - 3959779706285659/144115188075855872)^2)/pi^2
end
with fsolve. But i am getting following error message:
'Undefined function 'arg' for input arguments of type 'double'.
Error in myfun (line 2)
F = [((x(1) + (x(2) - 987)^2 - 24025)^(1/2)/2 - 8643/20)/(2*(x(1) + (x(2) - 987)^2 - 24025)^(1/2)) -
(6480000*((17*pi)/60 + arg(x(1)*i + x(2) - 259 - 1571*i))*(imag(x(1)) - real(x(2)) + 259))/(169*pi
Error in fsolve (line 241)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
'
Please help me out in this. Thanks

5 件のコメント

Matt J
Matt J 2013 年 4 月 29 日
編集済み: Matt J 2013 年 4 月 29 日
You haven't told us (and apparently not FSOLVE either) what arg() is and where it comes from. We would need to see more of your code, in particular the definition of your function, where you define arg(), and your call to FSOLVE.
satendra kumar
satendra kumar 2013 年 4 月 29 日
編集済み: Walter Roberson 2013 年 4 月 29 日
Okay, Here is the full code:-
1. Defination of function. This is main file.
if true
theta =([162.2, 45.1, 309]);
sigma =([.8, .6, 1.3, 2.0]);
X =([746, 629, 1571, 155]);
Y =([1393,375,259,987]);
d4 =864.3;
for j=1:3
theta(j)=(2*pi*theta(j)/360);
if theta(j)>(pi)
theta(j)=theta(j)-(2*pi);
end
end
for j=1:3
sigma(j)=(2*pi*sigma(j)/360);
if sigma(j)>(pi);
sigma(j)=sigma(j)-2*pi;
end
end
theta
sigma
%%SUM of Squers
syms x
syms y;
S=0;
for j=1:3
S=S+(((atan(x-X(j), y-Y(j))-theta(j)))/sigma(j))^2;
end
S=S+((((x-X(4)^2) + (y-Y(4))^2)^.5-d4)/sigma(4))^2
Sx=diff(S,x);
Sy=diff(S,y);
x0=[750 950];
[x fval]=fsolve(@myfun,x0)
end
File for fsolve:
if true
function F = myfun(x)
F = [ ((x(1) + (x(2) - 987)^2 - 24025)^(1/2)/2 - 8643/20)/(2*(x(1) + (x(2) - 987)^2 - 24025)^(1/2));
(14664628646633870009187528867840000*real(x(2)))/452869728063427961323810153909 - (14664628646633870009187528867840000*imag(x(1)))/452869728063427961323810153909 + (((x(1) + (x(2) - 987)^2 - 24025)^(1/2)/2 - 8643/20)*(2*x(2) - 1974))/(2*(x(1) + (x(2) - 987)^2 - 24025)^(1/2)) - 5132948614190041913371008122974671477375/231869300768475116197790798801408;
];
end
end
Shashank Prasanna
Shashank Prasanna 2013 年 4 月 29 日
Please format the code using the 'Code' button, it is very unreadable.
satendra kumar
satendra kumar 2013 年 4 月 29 日
Sorry for the inconvenience, Now i made it correct. Please look into it.
Walter Roberson
Walter Roberson 2013 年 4 月 29 日
? Your current function has no reference to arg(). Are you possibly using matlabFunction() to generate the function in some code you have not shown here? The myfun() you have shown here has no relationship to finding S or Sx or Sy.

サインインしてコメントする。

回答 (1 件)

Shashank Prasanna
Shashank Prasanna 2013 年 4 月 29 日

0 投票

Satendra, arg is not a function in MATLAB but you the function 'angle' computes the argument of the complex number which I believe you are trying to find. In your 'S' replace 'arg' with 'angle'

1 件のコメント

satendra kumar
satendra kumar 2013 年 4 月 29 日
編集済み: satendra kumar 2013 年 4 月 29 日
Thanks Shashank, But when i did that i got following error message:
Undefined function 'atan2' for input arguments of type 'sym'.
Error in angle (line 14)
p = atan2(imag(h), real(h));

サインインしてコメントする。

カテゴリ

質問済み:

2013 年 4 月 29 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by