From: yuan xia on
I want to make out x,my procedure is as follows:
function f=yt(x);
f=[exp(-x(1)*6.1)*x(6)+x(7)*exp(-x(2)*6.1)+(1-x(6)-x(7))*exp(-x(3)*6.1)-(1-0.6944);exp(-x(1)*28.15)*x(8)+x(9)*exp(-x(2)*28.15)+(1-x(8)-x(9))*exp(-x(3)*28.15)-(1-0.8992);exp(-x(1)*30.43)*x(10)+x(11)*exp(-x(2)*30.43)+(1-x(10)-x(11))*exp(-x(3)*30.43)-(1-0.8121);exp(-x(1)*11.76)*x(12)+x(13)*exp(-x(2)*11.76)+(1-x(12)-x(13))*exp(-x(3)*11.76)-(1-0.6721);exp(-x(1)*14.32)*x(14)+x(15)*exp(-x(2)*14.32)+(1-x(14)-x(15))*exp(-x(3)*14.32)-(1-0.5779);x(8)*(1-exp(-x(1)*28.15))-0.8992*x(10);x(9)*(1-exp(-x(2)*28.15))-0.8992*x(11);x(12)*(1-exp(-x(1)*11.76))-(1-0.6721)*x(14);x(13)*(1-exp(-x(2)*11.76))-(1-0.6721)*x(15);x(6)*exp(-x(1)*6.1)+x(10)(1-exp(-x(1)*30.43))-(1+0.8121-0.6944)*x(8);x(7)*exp(-x(2)*6.1)+x(11)(1-exp(-x(2)*30.43))-(1+0.8121-0.6944)*x(9);x(4)+x(8)*exp(-x(1)*28.15)+x(12)(1-exp(-x(1)*11.76))-(1-0.8992+0.6721+x(4)+x(5))*x(6);x(5)+x(9)*exp(-x(2)*28.15)+x(13)(1-exp(-x(2)*11.76))-(1-0.8992+0.6721+x
(4)+x(5))*x(7);x(6)*exp(-x(1)*6.1)+x(14)*(1-exp(-x(1)*14.32))-(1+0.5779-0.6944)*x(12);x(7)*exp(-x(2)*6.1)+x(15)*(1-exp(-x(2)*14.32))-(1+0.5779-0.6944)*x(13)];
>> x0=[0.8;0.5;0.3;0.5;0.2;0.5;0.2;0.5;0.2;0.5;0.2;0.5;0.2;0.5;0.2];
options=optimset('Display','off');
[x,fval,exitflag]=fsolve('yt',x0,options)
Error: File: C:\MATLAB7\work\yt.m Line: 2 Column: 626
()-indexing must appear last in an index expression.
Error in ==> fsolve at 180
fuser = feval(funfcn{3},x,varargin{:});
Can anyone help me,thanks very much!
From: Walter Roberson on
yuan xia wrote:
> I want to make out x,my procedure is as follows:
> function f=yt(x);
> f=[exp(-x(1)*6.1)*x(6)+x(7)*exp(-x(2)*6.1)+(1-x(6)-x(7))*exp(-x(3)*6.1)-(1-0.6944);exp(-x(1)*28.15)*x(8)+x(9)*exp(-x(2)*28.15)+(1-x(8)-x(9))*exp(-x(3)*28.15)-(1-0.8992);exp(-x(1)*30.43)*x(10)+x(11)*exp(-x(2)*30.43)+(1-x(10)-x(11))*exp(-x(3)*30.43)-(1-0.8121);exp(-x(1)*11.76)*x(12)+x(13)*exp(-x(2)*11.76)+(1-x(12)-x(13))*exp(-x(3)*11.76)-(1-0.6721);exp(-x(1)*14.32)*x(14)+x(15)*exp(-x(2)*14.32)+(1-x(14)-x(15))*exp(-x(3)*14.32)-(1-0.5779);x(8)*(1-exp(-x(1)*28.15))-0.8992*x(10);x(9)*(1-exp(-x(2)*28.15))-0.8992*x(11);x(12)*(1-exp(-x(1)*11.76))-(1-0.6721)*x(14);x(13)*(1-exp(-x(2)*11.76))-(1-0.6721)*x(15);x(6)*exp(-x(1)*6.1)+x(10)(1-exp(-x(1)*30.43))-(1+0.8121-0.6944)*x(8);x(7)*exp(-x(2)*6.1)+x(11)(1-exp(-x(2)*30.43))-(1+0.8121-0.6944)*x(9);x(4)+x(8)*exp(-x(1)*28.15)+x(12)(1-exp(-x(1)*11.76))-(1-0.8992+0.6721+x(4)+x(5))*x(6);x(5)+x(9)*exp(-x(2)*28.15)+x(13)(1-exp(-x(2)*11.76))-(1-0.8992+0.6721+x
> (4)+x(5))*x(7);x(6)*exp(-x(1)*6.1)+x(14)*(1-exp(-x(1)*14.32))-(1+0.5779-0.6944)*x(12);x(7)*exp(-x(2)*6.1)+x(15)*(1-exp(-x(2)*14.32))-(1+0.5779-0.6944)*x(13)];

> Error: File: C:\MATLAB7\work\yt.m Line: 2 Column: 626
> ()-indexing must appear last in an index expression.

It did tell you the exact line and column of the problem.

The sub-expression causing the problem is:

x(11)(1-exp(-x(2)*30.43)

Perhaps you meant to have an * between the x(11) and the rest. There is
no implicit multiplication in symbolic expressions.
From: Steven Lord on

"Walter Roberson" <roberson(a)hushmail.com> wrote in message
news:hq8sc6$n41$1(a)canopus.cc.umanitoba.ca...
> yuan xia wrote:
>> I want to make out x,my procedure is as follows:
>> function f=yt(x);
>> f=[exp(-x(1)*6.1)*x(6)+x(7)*exp(-x(2)*6.1)+(1-x(6)-x(7))*exp(-x(3)*6.1)-(1-0.6944);exp(-x(1)*28.15)*x(8)+x(9)*exp(-x(2)*28.15)+(1-x(8)-x(9))*exp(-x(3)*28.15)-(1-0.8992);exp(-x(1)*30.43)*x(10)+x(11)*exp(-x(2)*30.43)+(1-x(10)-x(11))*exp(-x(3)*30.43)-(1-0.8121);exp(-x(1)*11.76)*x(12)+x(13)*exp(-x(2)*11.76)+(1-x(12)-x(13))*exp(-x(3)*11.76)-(1-0.6721);exp(-x(1)*14.32)*x(14)+x(15)*exp(-x(2)*14.32)+(1-x(14)-x(15))*exp(-x(3)*14.32)-(1-0.5779);x(8)*(1-exp(-x(1)*28.15))-0.8992*x(10);x(9)*(1-exp(-x(2)*28.15))-0.8992*x(11);x(12)*(1-exp(-x(1)*11.76))-(1-0.6721)*x(14);x(13)*(1-exp(-x(2)*11.76))-(1-0.6721)*x(15);x(6)*exp(-x(1)*6.1)+x(10)(1-exp(-x(1)*30.43))-(1+0.8121-0.6944)*x(8);x(7)*exp(-x(2)*6.1)+x(11)(1-exp(-x(2)*30.43))-(1+0.8121-0.6944)*x(9);x(4)+x(8)*exp(-x(1)*28.15)+x(12)(1-exp(-x(1)*11.76))-(1-0.8992+0.6721+x(4)+x(5))*x(6);x(5)+x(9)*exp(-x(2)*28.15)+x(13)(1-exp(-x(2)*11.76))-(1-0.8992+0.6721+x
>> (4)+x(5))*x(7);x(6)*exp(-x(1)*6.1)+x(14)*(1-exp(-x(1)*14.32))-(1+0.5779-0.6944)*x(12);x(7)*exp(-x(2)*6.1)+x(15)*(1-exp(-x(2)*14.32))-(1+0.5779-0.6944)*x(13)];
>
>> Error: File: C:\MATLAB7\work\yt.m Line: 2 Column: 626
>> ()-indexing must appear last in an index expression.
>
> It did tell you the exact line and column of the problem.
>
> The sub-expression causing the problem is:
>
> x(11)(1-exp(-x(2)*30.43)
>
> Perhaps you meant to have an * between the x(11) and the rest. There is no
> implicit multiplication in symbolic expressions.

Another suggestion; break your expression for f onto multiple lines, to make
it easier to read and easier to tell exactly what's being used to compute
each element of f.

f=[exp(-x(1)*6.1)*x(6)+x(7)*exp(-x(2)*6.1)+(1-x(6)-x(7))*exp(-x(3)*6.1)-(1-0.6944);
....
exp(-x(1)*28.15)*x(8)+x(9)*exp(-x(2)*28.15)+(1-x(8)-x(9))*exp(-x(3)*28.15)-(1-0.8992);
....
exp(-x(1)*30.43)*x(10)+x(11)*exp(-x(2)*30.43)+(1-x(10)-x(11))*exp(-x(3)*30.43)-(1-0.8121);
....
exp(-x(1)*11.76)*x(12)+x(13)*exp(-x(2)*11.76)+(1-x(12)-x(13))*exp(-x(3)*11.76)-(1-0.6721);
.....
% etc

Assuming there are no line breaks in the message as posted, isn't that a
little easier to read?

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


 | 
Pages: 1
Prev: cognitive radio simulation
Next: Simulation Time