how to add 2( two) function

조회 수: 32 (최근 30일)
vaya putra
vaya putra 2018년 8월 24일
댓글: vaya putra 2018년 8월 24일
dear Matlab I have 2 functions
q1 = @(p,T, bhp) WI .* (rho(p(w1),T(w1))./mu(p(w1),T(w1))) .* (p_conn(bhp,bhT)-p(w1));
q2 = @(p,T, bhp)-WI .* (rho(p(w2),T(w2))./mu(p(w2),T(w2))) .* (p_conn(bhp,bhT)-p(w2));
how to add that 2 function.I try
q_conn = q1+q2;
i got error
Undefined operator '+' for input arguments of type 'function_handle'.

채택된 답변

Ji Hoon Jeong
Ji Hoon Jeong 2018년 8월 24일
Hi vaya putra
This error comes out because you are basically adding two "functions". What you want to do is probably adding two functions "output"
So, you should make another function which takes inputs and feed them to each function and add the output
this is an example.
q1 = @(a,b) a+b;
q2 = @(a,b) a*b;
q3 = @(a,b) q1(a,b) + q2(a,b);
for your code, this might help
q_conn = @(p,T, bhp) q1(p,T, bhp)+q2(p,T, bhp)
  댓글 수: 1
vaya putra
vaya putra 2018년 8월 24일
thank you, for your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by