find intersection of refline and function

How do I find the point of intersection? i am now getting:
Undefined operator '-' for input arguments of type 'matlab.graphics.primitive.Line'.
Error in jetengine (line 66)
fun=Umix2 - Intersection;
------
Umix1=UNasa(Tref,Sp(iSp1))*YiO2+UNasa(Tref,Sp(iSp2))*YiN2+UNasa(Tref,Sp(iSp5))*YiFuel
Umix2=UNasa(T,Sp(iSp1))*YiO2+UNasa(T,Sp(iSp2))*YiN2+UNasa(T,Sp(iSp5))*YiFuel;
plot(T,Umix2)
hold on
plot(T,Umix1)
hold off
Intersection=refline(0,Umix1);
fun=Umix2 - Intersection;
x = fzero(fun,300)
----
The function is Umix2, the horizontal line is Intersection.

Respuestas (1)

Star Strider
Star Strider el 6 de Oct. de 2017
Since I don’t have your data, this is just a guess:
Umix2_fun = @(T) UNasa(T,Sp(iSp1))*YiO2+UNasa(T,Sp(iSp2))*YiN2+UNasa(T,Sp(iSp5))*YiFuel;
x = fzero(@(T) Umix2_fun - Umix1, 300)
NOTE — This is obviously UNTESTED CODE. It will probably work.

2 comentarios

Thomas Janss
Thomas Janss el 6 de Oct. de 2017
Editada: Thomas Janss el 6 de Oct. de 2017
Unfortunatly it does not work ;(
Error using fzero (line 287) FZERO cannot continue because user-supplied function_handle ==> @(T)Umix2_fun-Umix1 failed with the error below.
Undefined function 'minus' for input arguments of type 'function_handle'.
Error in jetengine (line 61)
x = fzero(@(T) Umix2_fun - Umix1, 300)
Code at the moment is:
Umix1=UNasa(Tref,Sp(iSp1))*YiO2+UNasa(Tref,Sp(iSp2))*YiN2+UNasa(Tref,Sp(iSp5))*YiFuel
Umix2_fun = @(T) UNasa(T,Sp(iSp1))*YiO2+UNasa(T,Sp(iSp2))*YiN2+UNasa(T,Sp(iSp5))*YiFuel;
x = fzero(@(T) Umix2_fun - Umix1, 300)
plot(T,Umix2)
hold on
plot(T,Umix1)
hold off
That’s the problem of not being able to completely test code before posting it.
Try this:
Umix2_fun = @(T) UNasa(T,Sp(iSp1))*YiO2+UNasa(T,Sp(iSp2))*YiN2+UNasa(T,Sp(iSp5))*YiFuel;
x = fzero(@(T) Umix2_fun(T) - Umix1, 300)

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Oct. de 2017

Comentada:

el 6 de Oct. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by