Thanks Doug. I corrected the x problem and also realized I didn't supply
initial guesses for all the X variables. But I'm still not there. Here's
the code:
>> function y = f (X)
y = zeros (12, 1);
y(1) = Y_e*X(1)*sin(X(2)) +dStat*X(5)/2 + O;
y(2) = X(4) -X(3) + Og_o;
y(3) = X(7);
y(4) = X(1)*Tau^2*(Og_o + X(3))*X(4) +Cf*X(8);
---
---
---
y(50) = X(7) -X(26) -X(27) -X(28) -X(29) -X(30) -X(31) -X(32) -X(33) -X(34)
-X(35) -X(36) -X(37) -X(38);
y(51) = X(8) -X(39) -X(40) -X(41) -X(42) -X(43) -X(44) -X(45) -X(46) -X(47)
-X(48) -X(49) -X(50) -X(51);
endfunction
>> [X, fval, info] = fsolve
>> (@f,[0.1;0.01;1024;4.;-1.0;0.001;0.0;0.5;154.;71000;0.000007;0.000005;
0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0])
error: 'Y_e' undefined near line 3 column 8
error: called from
f at line 3 column 6
fsolve at line 236 column 8
>>
I'm pressed for time and so can't read all of the manual I should. I
appreciate your help.
Tom
--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
The variable Y_e is not passed into the function f, so f cannot access it. You need to pass that variable into the function f, or make Y_e a global variable.
Passing Y_e into f would mean you have to give f two arguments: f(X,Y) instead of f(X). I haven't used fsolve myself, so I'm not sure whether it accepts multiple arguments. However, there is a simple workaround that I think should do the trick.
First give f another argument in the place of Y_e
function y = f (X,Y)
y = zeros (12, 1);
y(1) = Y*X(1)*sin(X(2)) +dStat*X(5)/2 + O;
y(2) = X(4) -X(3) + Og_o;
y(3) = X(7);
y(4) = X(1)*Tau^2*(Og_o + X(3))*X(4) +Cf*X(8);
---
---
---
y(50) = X(7) -X(26) -X(27) -X(28) -X(29) -X(30) -X(31) -X(32) -X(33) -X(34)
-X(35) -X(36) -X(37) -X(38);
y(51) = X(8) -X(39) -X(40) -X(41) -X(42) -X(43) -X(44) -X(45) -X(46) -X(47)
-X(48) -X(49) -X(50) -X(51);
endfunction
Then define a supplementary function g with a single argument X which returns f(X,Y_e), and use fsolve on g instead.
Y_e = cosh(Alpha*X_bar) - cos(Alpha*X_bar) + Eta*(sinh(Alpha*X_bar) - sin(Alpha*X_bar));
g = @(X) f(X,Y_e);
[X, fval, info] = fsolve(@g,[0.1;0.01;1024;4.;-1.0;0.001;0.0;0.5;154.;71000;0.000007;0.000005;
0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0])