USING newton method optimization (getting error in 'xx(1)=x') .

2 Ansichten (letzte 30 Tage)
RAHUL KUMAR
RAHUL KUMAR am 1 Aug. 2019
Beantwortet: Bobby Huxford am 1 Aug. 2019
rho_ss=8000;
rho_cop=8960;
x=[.001;.0014;.005;.007;.3];
D_i=x(1);D_io=x(2);D_o=x(3);D_oo=x(4);L=x(5);
wi=rho_ss*pi*D_io*(D_io-D_i)*L
wo=rho_cop*pi*D_o*(D_oo-D_o)*L
f=@(x) ((wi+wo)-.050)^2
fd=str2sym('((wi+wo)-.050)^2')
%f1=diff(fd,1)
%f2=diff(fd,2)
f1=@(x) (2.0*wi + 2.0*wo - 0.1)
f2=@(x) (2)
N=100; %no of iteration
err=.01; %result accuracy
xx(1)=x;
for i=1:N
x(i)=x-(f1(x)/f2(x));
j=i+1;
xx(j)=x;
Err=abs(xx(j))-abs(xx(j-1));
if Err<err,break;end
end

Antworten (1)

Bobby Huxford
Bobby Huxford am 1 Aug. 2019
It would be easier to answer this if you wrote a question along with the code...
But the line xx(1)=x; will give you an error because you are trying to assign the 5 values in x to the first space in xx.
The line of code you may be looking for is:
However I am not sure what it is you are trying to do, so this could be wrong.
xx = x(1);

Kategorien

Mehr zu Nonlinear Optimization finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by