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.

回答(1 个)

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 个评论

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)

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by