Info

この質問は閉じられています。 編集または回答するには再度開いてください。

it is showing not enough input arguments

1 回表示 (過去 30 日間)
vaibhav mohadikar
vaibhav mohadikar 2016 年 4 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
function out = g(x1 , x2)
out = x1 * x2 - 1140;
function [dGdX1 dGdX2] = dGdX(x1 , x2)
dGdX1 = x2 ;
dGdX2 = x1 ;
clc ;
clear ;
close a l l ;
format short g ;
% −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− %
mu_x1 = 38;
sigma_x1 = 3.8;
mu_x2 = 54;
sigma_x2 = 2.7;
x1 = mu_x1
x2 = mu_x2
[dg_dx1 dg_dx2] = dGdX(x1 , x2 ) ;
g_ = g(x1 , x2)
beta = g_ / sqrt (( dg_dx1 * sigma_x1)^2 + (dg_dx2 * sigma_x2)^2)
alpha_1 = -dg_dx1 * sigma_x1 / sqrt (( dg_dx1 * sigma_x1)^2 +...
(dg_dx2 * sigma_x2 )^2);
alpha_2 = -dg_dx2 * sigma_x2 / sqrt (( dg_dx1 * sigma_x1)^2 +...
(dg_dx2 * sigma_x2 )^2);
u1 = beta * alpha_1 ;
u2 = beta * alpha_2 ;
x1 = mu_x1 + u1 * sigma_x1
x2 = mu_x2 + u2 * sigma_x2
epsilon = 1.0;
while epsilon > 1E-3
g_ = g(x1 , x2)
[dg_dx1 dg_dx2] = dGdX(x1 , x2 ) ;
beta_old = beta ;
beta = (g_ - dg_dx1 * sigma_x1 * u1 - dg_dx2 * sigma_x2 * u2 )...
/ sqrt (( dg_dx1 * sigma_x1)^2 + (dg_dx2 * sigma_x2)^2)
epsilon = abs( beta - beta_old ) / beta_old
alpha_1 = -dg_dx1 * sigma_x1 / sqrt (( dg_dx1 * sigma_x1)^2 +...
(dg_dx2 * sigma_x2 )^2);
alpha_2 = -dg_dx2 * sigma_x2 / sqrt (( dg_dx1 * sigma_x1)^2 +...
(dg_dx2 * sigma_x2 )^2);
u1 = beta * alpha_1 ;
u2 = beta * alpha_2 ;
x1 = mu_x1 + u1 * sigma_x1
x2 = mu_x2 + u2 * sigma_x2
end
can any one help?
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 9 日
What is the aim of assigning variables then clearing them?
dGdX1 = x2 ;
dGdX2 = x1 ;
clc ;
clear
Jan
Jan 2016 年 4 月 9 日
編集済み: Jan 2016 年 4 月 9 日
"close a l l ;"? Do you mean "close all;" without magic spaces?
You forgot to post the complete error message. Most of all the line, which causes the error, would be a useful information.

回答 (1 件)

Kuifeng
Kuifeng 2016 年 4 月 10 日
%Remove the following lines from the code
clc ;
clear ;
close a l l ;
  2 件のコメント
vaibhav mohadikar
vaibhav mohadikar 2016 年 4 月 10 日
Thank you but its still keep saying that not enough input arguments in line 2.
Walter Roberson
Walter Roberson 2016 年 4 月 11 日
And lucky for you that it did, as otherwise your code would recurse infinitely. You invoke [dg_dx1 dg_dx2] = dGdX(x1 , x2 ) ; within your dGdX code, so it would go back and start the routine all over again, and hit that line and go back and start the routine all over again, and so on.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by