[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: matlab lsqnonlin equivalent in octave but with only two parameters a
Re: matlab lsqnonlin equivalent in octave but with only two parameters and Global Variable issue in a function i found
Mon, 16 Feb 2015 02:10:49 -0800 (PST)
I often run pkg load all which loads among others the optim package and in
the src directory where the other packages are is an .m file that needs to
be run to install them. I did that, although others might not
realise so it is good to mention it.
I kind of just thought someone might be curious like me to look into what I
have done so thought I would provide the relevant information.
I think I have solved a bit of my problems with advice from some friends,
from a function originally as written in the previous post.
I changed it to this:
function y = myfunc_b0_1(b0)
#[FNAME_Func, FPATH_func, FLTIDX_Func] = uigetfile ('This is to select
the function so that it is in the load path');
#Fid_func = fopen(FNAME_Func);
VAL1a = -q*Voc/(b0(1) *kB*T)
This helps me see if and what is going on.
my call to the function is this
global Isc = current(1)
global Isc = 0.031085
global Voc = -0.75180
global Voc = voltage(VocPos)
#Voc = -0.7518
global T = 26.5 # the eqn in func does not work below 26.5 need to find
out a better way
q = -1.6021765e-19
global kB = 1.3806488e-23
#Initial values of n0, Rs0, Rsh0
b0=[n0, Rs0, Rsh0]'
b0=[1, 1, Rsh0] I put these values to help the function not to produce
errors otherwise I exceed realmax/realmin in the function.
#in matlab this is b = nonlinsq('myfunc' or 'myfunc_b0_1', b0)
with further work that I have done asking people, not sure exactly but good
thing is the program kind of works.
For those who ask if you can use fsolve and nonlinsq in the same way i.e.
nonlinsq(func, initial conditions) I think they can be as I am doing that
By themselves from the variables produce values
BUT I am running into a problem still.
When I call fsolve to run the function and solve it gives me this:
VAL1 = 0.035903
VAL1a = (0x0)
VAL2 = (0x0)
VAL2a = 1.3095e-143
VAL2b = 0.80252
error: myfunc_b0_1: operator *: nonconformant arguments (op1 is
0x0, op2 is 255x1)
error: called from:
.m at line 44, column 5
on\fsolve.m at line 201, column 8
referring to this line in fsolve:
## Initial evaluation.
## Handle arbitrary shapes of x and f and remember them.
fvec = fcn (reshape (x, xsiz));
My curiosity is how my variables cause  (0x0)
while calculating values and inputting them seperately in without fsolve
I will try to find out why the other function did not work and had
global variables but since i have made part of it work i'm trying to
ps. my data columns are 255 columns in length so i am not sure if it is
desired for me to put them up here.
lets say it ranges
V= -0.0019836 : -0.50583, equally space at (0.0019836) between each value
I = 0.031085 : 0.026974 with a curve in the shape of a gentle slope
View this message in context:
Sent from the Octave - General mailing list archive at Nabble.com.