[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another fsolve question -- Beginner
From: |
MMolloy |
Subject: |
Re: Another fsolve question -- Beginner |
Date: |
Thu, 26 May 2011 14:39:12 -0700 (PDT) |
Hi Jordi,
Many thanks for your reply. I had the ".*" in there so an earlier version
would perform the operation on an element-by-element basis for the matrices
I was using. I've tried some variations of what you have suggested:
load E1.csv;
function y = f (x)
y = zeros(10,1);
y = 1.14*exp( -x/1.14 ) - 3.79*exp( -x/3.79 ) - E1
endfunction
load RG.csv;
[x, fval, info] = fsolve(@f, RG);
AND
function y = f (x)
y = zeros(10,1);
y = 1.14*exp( -x/1.14 ) - 3.79*exp( -x/3.79 ) - E1
endfunction
load E1.csv;
load RG.csv;
[x, fval, info] = fsolve(@f, RG);
Both return the error that "E1 is undefined". However, if I define "E1"
inside the function it works fine:
function y = f (x)
y = zeros(10,1);
E1 = [1;2;3;4;5;6;7;8;9;10]
y = 1.14*exp( -x/1.14 ) - 3.79*exp( -x/3.79 ) - E1
endfunction
load RG.csv;
[x, fval, info] = fsolve(@f, RG);
All good so far. Now the trouble begins when "E1" is a 10000x1 matrix -
which is what I would like to do! If I load "E1" outside the function then
the function returns the "undefined" error. If I call it inside the function
then my RAM gets max'd out.
Output from "ps aux":
4607 2.7 50.3 1108628 903952 pts/0 R+ 22:05 0:51 octave3.2
That's 900MB's - and it grows quickly!
I thought if I could split my matrix into 10000 1x1 matrices then I could
run some loop to perform "fsolve" on each matrix - this is where the "for"
loops came in and made me look silly!
I'm honestly stumped - I can't see how the function can call the relevant
element of "E1" for its corresponding "guess" at x.
Again, I really appreciate your help - I've had no formal programming
training and I'm learning as I go!
Thanks,
M.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Another-fsolve-question-Beginner-tp3553080p3553745.html
Sent from the Octave - General mailing list archive at Nabble.com.