Do the index notation allowed in subs command..If not, what is the alternative... Plz debug the following program.

2 vues (au cours des 30 derniers jours)
clc
clear all
syms x1 x2
conv=0.001;
g(2)=x1^3+x2^3-18
mux1=input('enter mean of x1')
mux2=input('enter mean of x2')
sdx1=input('enter sd of x1')
sdx2=input('enter sd of x2')
mu=subs(g(2),{x1,x2},{mux1,mux2})
var=[subs(diff(g(2),x1),{x1,x2},{mux1,mux2})*sdx1]^2+ ...
[subs(diff(g(2),x2),{x1,x2},{mux1,mux2})*sdx2]^2
sd=sqrt(var)
betav=mu/sd
alpha1=-sqrt([subs(diff(g(2),x1),{x1,x2},{mux1,mux2})*sdx1]^2)/sd
alpha2=-sqrt([subs(diff(g(2),x2),{x1,x2},{mux1,mux2})*sdx2]^2)/sd
% x1_1new=mux1+beta*sdx1*alpha1
% x2_1new=mux2+beta*sdx2*alpha2
% u1_1=(x1_1new-mux1)/sdx1
% u2_1=(x2_1new-mux2)/sdx2
% mu_new=subs(g,{x1,x2},{x1_1new,x2_1new})
% var_new=[subs(diff(g,x1),{x1,x2},{x1_1new,x2_1new})*sdx1]^2+ ...
% [subs(diff(g,x2),{x1,x2},{x1_1new,x2_1new})*sdx2]^2
% sd_new=sqrt(var_new)
% novar_new=[subs(diff(g,x1),{x1,x2},{x1_1new,x2_1new})*sdx1]*u1_1+ ...
% [subs(diff(g,x2),{x1,x2},{x1_1new,x2_1new})*sdx2]*u2_1
% beta_1new=(mu_new-novar_new)/sd_new
% iterations begin
i=2;
beta(1)=0;
beta(2)=betav;
mu(1)=mu;
while ((abs(beta(i)-beta(i-1)))/beta(i-1))>conv
i
x1(1)=0;
x2(1)=0;
x1(i)= mux1+beta(i)*sdx1*alpha1
x2(i)= mux2+beta(i)*sdx2*alpha2
u1(i)= (x1(i)-mux1)/sdx1
u2(i)= (x2(i)-mux2)/sdx2
g
x1(i)
x2(i)
mu(i)=subs(g,{x1,x2},{x1(i),x2(i)})
var(i)=[subs(diff(g,x1),{x1,x2},{x1(i),x2(i)})*sdx1]^2+ ...
[subs(diff(g,x2),{x1,x2},{x1(i),x2(i)})*sdx2]^2
sd(i)=sqrt(var(i))
novar(i)=[subs(diff(g,x1),{x1,x2},{x1(i),x2(i)})*sdx1]*u1(i)+ ...
[subs(diff(g,x2),{x1,x2},{x1(i),x2(i)})*sdx2]*u2(i)
beta(i)=(mu(i)-novar(i))/sd(i)
alpha1(i)=-sqrt([subs(diff(g,x1),{x1,x2},{x1(i),x2(i)})*sdx1]^2)/sd(i)
alpha2(i)=-sqrt([subs(diff(g,x2),{x1,x2},{x1(i),x2(i)})*sdx2]^2)/sd(i)
i=i+1
end
beta(i)
  2 commentaires
Jan
Jan le 23 Avr 2013
At first start to read the "? Help" link. Then use what you have found there to format your code until it is readable. In the next step, show us, where the problem is instead of letting us guess the details. If you ask for an alternative, be as exact as possible: Alternative to what?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by