Using interp1 within vpasolve
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Adam Zieser
el 13 de Jul. de 2021
Comentada: Walter Roberson
el 14 de Jul. de 2021
I'm having difficulty with the following situation trying to numerically solve an equation (with vpasolve, or something similar) that uses interp1-interpolated data within the solve. Consider:
with implementation:
syms Z;
vpasolve(Z.^4 == ( muL .* interp1(X,GH,Z) - muH .* interp1(X,GL,Z) )./( muL .* interp1(X,FH,Z) ...
- muH .* interp1(X,FL,Z) ), Z);
where
and
are constants, so that the μ-values are constant, and F and G are 2D matrices squeezed to 1D. These 1D matrices are known on a grid Z = 5:15. Then, I'm attempting to solve this equation for Z, which presumably has real-numbered values
as solution. I assumed vpasolve worked iteratively, with an initial guessed query of Z, such that interp1 with (syms Z) is valid to use inside vpasolve. Of course, this doesn't work.
as solution. I assumed vpasolve worked iteratively, with an initial guessed query of Z, such that interp1 with (syms Z) is valid to use inside vpasolve. Of course, this doesn't work. Is there any way to work this? I've simplified things for ease of explanation, but suffice it to say that just doing a polynomial fit on F and G instead of using interp1 is not on the table: the data in the F and G grids need to only be interpolated for non-integer values of Z. Here's some data, just to make it easier to run if needed.
muH = 0.178125;
muL = 0.142500;
GL = [0.2684 0.2690 0.2696 0.2704 0.2714 0.2724 0.2734 0.2746 0.2756 0.2768 0.2781];
GH = [0.3258 0.3280 0.3307 0.3342 0.3381 0.3431 0.3474 0.3520 0.3568 0.3618 0.3670];
FL = 1E-6 .* [0.4234 0.4180 0.4100 0.4017 0.3932 0.3840 0.3766 0.3698 0.3628 0.3554 0.3480];
FH = 1E-6 .* [0.4234 0.4180 0.4100 0.4017 0.3932 0.3840 0.3766 0.3698 0.3628 0.3554 0.3480];
0 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Jul. de 2021
Turn it into a numeric system
z0 = 1;
muH = 0.178125;
muL = 0.142500;
GL = [0.2684 0.2690 0.2696 0.2704 0.2714 0.2724 0.2734 0.2746 0.2756 0.2768 0.2781];
GH = [0.3258 0.3280 0.3307 0.3342 0.3381 0.3431 0.3474 0.3520 0.3568 0.3618 0.3670];
FL = 1E-6 .* [0.4234 0.4180 0.4100 0.4017 0.3932 0.3840 0.3766 0.3698 0.3628 0.3554 0.3480];
FH = 1E-6 .* [0.4234 0.4180 0.4100 0.4017 0.3932 0.3840 0.3766 0.3698 0.3628 0.3554 0.3480];
best_z = fsolve(@(Z) Z.^4 - (( muL .* interp1(X,GH,Z,'linear','extrap') - muH .* interp1(X,GL,Z,'linear','extrap') )./( muL .* interp1(X,FH,Z,'linear','extrap') ...
- muH .* interp1(X,FL,Z,'linear','extrap') )), z0);
5 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Equation Solving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!