Hello~
I'm beginner of numerical calculation with matlab.
I'm trying to solve a system of nonlinear equations by newton method.
(i.e. X(k+1) = X(k)-inv(jacobian(F(X(k)))*F(X(k)) )
but i don't know what this error message say.
( index must be a positive integer or logical. )
following is my code.
====================================
x=1.000000;
y=1.000000;
z=1.000000;
X=[x
y
z];
for n=1:1:10
fprintf('iteration check point ++\n');
X=[x
y
z];
FX=[f1(x,y,z)
f2(x,y,z)
f3(x,y,z)];
DF=[f1x(x,y,z) f2x(x,y,z) f3x(x,y,z)
f1y(x,y,z) f2y(x,y,z) f3y(x,y,z)
f1z(x,y,z) f2z(x,y,z) f3z(x,y,z)];
H=inv(DF)*FX;
X=X-H;
x=X(1,1);
y=X(2,1);
z=X(3,1);
end
====================================
f1,f2,and f3 is a system of nonliear equtions(external function)
(f1: x*y-z^2-1=0
f2: x*y*z+y^2-x^2+2=0
f3: exp(x)+z-exp(y)+3)
and f1x means (df1/dx)(derivative function, for example.
When i run this mfile,
the error say that ( index must be a positive integer or logical. FX=[f1(x,y,z) )
i know the jacobian function. i dont wanna use this fuction but use 'DF' matrix I made.
well.....any... is there somebody to help me.plz.....
|
|
0
|
|
|
|
Reply
|
JKA
|
4/20/2010 4:49:04 AM |
|
"JKA tom" <everjkahn@hanmail.net> wrote in message <hqjbo0$3qd$1@fred.mathworks.com>...
> When i run this mfile,
> the error say that ( index must be a positive integer or logical. FX=[f1(x,y,z) )
>
That error happens if for some reason Matlab see F1 as (array) VARIABLE and not as FUNCTION. Are you sure you declare the function F1 properly, and it is not cleared or overshadowed by the variable having a same name? Use "WHICH F1" command to make a diagnostic.
Bruno
|
|
0
|
|
|
|
Reply
|
Bruno
|
4/20/2010 6:27:20 AM
|
|
>
> That error happens if for some reason Matlab see F1 as (array) VARIABLE and not as FUNCTION. Are you sure you declare the function F1 properly, and it is not cleared or overshadowed by the variable having a same name? Use "WHICH F1" command to make a diagnostic.
>
======
Thanks for you reply.
But... can you explain what i should do to solve this probem conctretely?
what does it mean to 'Use "WHICH F1" command to make a diagnostic'?
|
|
0
|
|
|
|
Reply
|
JKA
|
4/20/2010 7:04:04 AM
|
|
>
> That error happens if for some reason Matlab see F1 as (array) VARIABLE and not as FUNCTION. Are you sure you declare the function F1 properly, and it is not cleared or overshadowed by the variable having a same name? Use "WHICH F1" command to make a diagnostic.
>
======
Thanks for you reply.
But... can you explain what i should do to solve this probem conctretely?
what does it mean to 'Use "WHICH F1" command to make a diagnostic'?
|
|
0
|
|
|
|
Reply
|
JKA
|
4/20/2010 7:06:04 AM
|
|
>
> That error happens if for some reason Matlab see F1 as (array) VARIABLE and not as FUNCTION. Are you sure you declare the function F1 properly, and it is not cleared or overshadowed by the variable having a same name? Use "WHICH F1" command to make a diagnostic.
>
======
Thanks for you reply.
But... can you explain what i should do to solve this probem conctretely?
what does it mean to 'Use "WHICH F1" command to make a diagnostic'?
|
|
0
|
|
|
|
Reply
|
JKA
|
4/20/2010 7:07:04 AM
|
|
"JKA tom" <everjkahn@hanmail.net> wrote in message <hqjjqo$f5i$1@fred.mathworks.com>...
> >
> > That error happens if for some reason Matlab see F1 as (array) VARIABLE and not as FUNCTION. Are you sure you declare the function F1 properly, and it is not cleared or overshadowed by the variable having a same name? Use "WHICH F1" command to make a diagnostic.
> >
> ======
> Thanks for you reply.
> But... can you explain what i should do to solve this probem conctretely?
> what does it mean to 'Use "WHICH F1" command to make a diagnostic'?
help which
The following illustrate with SUM instead of F1.
>> sum(0)
ans =
0
>> which sum
built-in (C:\Program Files\MATLAB\R2010a\toolbox\matlab\datafun\@uint8\sum) % uint8 method
>> sum=[1 2 3]
sum =
1 2 3
>> which sum
sum is a variable.
>> sum(0)
??? Subscript indices must either be real positive integers or logicals.
% Bruno
|
|
0
|
|
|
|
Reply
|
Bruno
|
4/20/2010 7:27:04 AM
|
|
Wow~GOT IT
Thanks a lot~
|
|
0
|
|
|
|
Reply
|
JKA
|
4/20/2010 10:24:03 AM
|
|
|
6 Replies
290 Views
(page loaded in 0.019 seconds)
Similiar Articles: what.....i don't know what it happened!(index must be a positive ...PDF_DEL_VT_tsts(del_vt, z); Hi, I don't see ... be real positive integers or ... index must be a positive integer or logical ... The scenario where this happens is when I ... ??? Attempted to access e(1,0); index must be a positive integer ...===== Why are you trying to use non-integer indices when you know these locations in your array don't ... in gui???? - comp.soft-sys ... index must be a positive integer or logical ... Subscript indices must either be real positive integers or ...... pdf at 101 > test = PDF_DEL_VT_tsts(del_vt, z); Hi, I don't see ... index must be a positive integer or logical. - comp.soft-sys ... Attempted to access e(1,0); index must ... selection problem for checkboxes in uitable - comp.soft-sys.matlab ...Or do you at least see the described behavior if you ... However, I don't give up yet. Hey folks, any matlab ... uitable - 'logical' - checkboxes - comp.soft-sys.matlab ... Windowed sinc - comp.dspAnyway, are you raising the question: "What happens ... In any case I don't see that it matters because, in ... simple; for the continuous-tim= e > >> >index, the integer part ... Sampling: What Nyquist Didn't Say, and What to Do About It - comp ...Sampling at a rate of F/N when N is integer will never ... graphics (treating tables as graphics) that you must ... >>> >>> I don't see anything at all wrong with the font. How to write testbench file? - comp.lang.vhdlI don't know anything about your design but ... The same thing happens when an integer counter under/over ... In this case, the MSB of address must be '0' for the index ... Sockets in gfortran? - comp.lang.fortran* These routines must not directly or ... full year yet as a linux user, so I don't really see a ... was giving a garbage value (a big positive number), but it wasn't ... VBOs vs Display Lists - lets test it out! - comp.graphics.api ...Well, I'd say it a bit more positive: After this "crude ... NeHe lesson 45 demo (255 512-triangle strips but index ... I don't know, but I'm sticking with VBOs ... input & output in assembly - comp.lang.asm.x86In other words, it's probably logical ... lowest level to understand what happens. Once you have understood it, you don't ... Well, I don't know about Win16. dosemu is ... what.....i don't know what it happened!(index must be a positive ...PDF_DEL_VT_tsts(del_vt, z); Hi, I don't see ... be real positive integers or ... index must be a positive integer or logical ... The scenario where this happens is when I ... Fiction - Salon.comYou must calm down. Her eyes looked past me. I picked ... with it – better to not pretend it hadn’t happened. ... I don’t know how else to say it. No one else who’s read ... 7/24/2012 5:24:25 PM
|