Computational problem!!!

Hi I have a problem with a matrix calculation. This code doesn't work because I can't explain to the code that the part that is elevated at the cube is a number and not a vector. How could I do ??? Regards
function F=System11(x)
m=5;
n=6;
g=m*n;
pc=(1:1:m);
pr=(m+1):m:((m*(n-1))+1);
ur=(2*m:m:(m*n));
uc=((m*(n-1))+2):1:((m*n)-1);
F=zeros(2*g,1);
%%%%
for p=2:1:(n-1)
cc=(2+(m*(p-1))):1:(m*p-1);
F(cc,1)=x(cc)-(x(g+cc,1))^3;
end
F(pc,1)=x(pc)-(x(g+pc))^3;
F(pr,1)=x(pr)-(x(g+pr))^3;
F(ur,1)=x(ur)-(x(g+ur))^3;
F(uc,1)=x(uc)-(x(g+uc))^3;
%%%%
for p=2:1:(n-1)
cc=(2+(m*(p-1))):1:(m*p-1);
F(g+cc,1)=x(g+cc)-6;
end
F(g+pc,1)=x(g+pc)-1;
F(g+pr,1)=x(g+pr)-2;
F(g+ur,1)=x(g+ur)-3;
F(g+uc,1)=x(g+uc)-4;
end
SOLVER
m=5;
n=6;
g=n*m;
%Initial Condition
KI=ones(g,1);
TI=ones(g,1);
iniz = [KI; TI];
options=optimset('Display','iter');
[x,fval,exitflag,output,JAC] = fsolve(@System11,iniz,options);

 Accepted Answer

Daniel Shub
Daniel Shub on 26 Mar 2012

0 votes

A stab here ... There is a difference between x^3 and x.^3, just like there is a difference between x.*y and x*y.

More Answers (0)

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!