Van der Waals equation - Newton's method
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Blanca Mir Pou
il 24 Mar 2020
Commentato: Blanca Mir Pou
il 25 Mar 2020
Hi
I'm stuck and I keep getting this error
Not enough input arguments.
Error in fun (line 4)
F(1) = log((3*x - 1)/(3*y - 1)) + 9/(4*T) * (1/x - 1/y) - 1/(3*x - 1) + 1/(3*y - 1);
Error in newton_ndim (line 6)
resd = [norm(feval(F,xk))];
Error in practica5 (line 16)
[XK,resd,n]=newton_ndim(@fun,X,tol,itmax);
Here is my main script
X = [1.2 ; 0.8];
Vk = [];
tol = 1e-16;
itmax = 100;
for T = 0.99:-0.01:0.85
[XK,resd,n]=newton_ndim(@fun,X,tol,itmax);
Vk=[Vk XK(:,end)];
X = XK(:,end);
end
The function I'm trying to solve is this one, obtained from Van der Waals equation
function F = fun (X,T)
x = X(1); y = X(2);
F(1) = log((3*x - 1)/(3*y - 1)) + 9/(4*T) * (1/x - 1/y) - 1/(3*x - 1) + 1/(3*y - 1);
F(2) = (8*T)/3 * (1/(3*x-1) - 1/(3*y-1)) - 1/x^2 + 1/y^2;
end
Do you know how to solve this?
0 Commenti
Risposta accettata
Are Mjaavatten
il 25 Mar 2020
In your code, newton_ndim does not know the value of T and so cannot call fun(X,T). You can probably fix this by defining an inline function (here called ffun) inside your loop:
for T = 0.99:-0.01:0.85
ffun = @(X) fun(X,T);
[XK,resd,n]=newton_ndim(ffun,X,tol,itmax);
Vk=[Vk XK(:,end)];
X = XK(:,end);
end
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!