필터 지우기
필터 지우기

Error in using Inline function and fzero

조회 수: 2 (최근 30일)
Venkatesh M Deshpande
Venkatesh M Deshpande 2014년 3월 20일
댓글: Venkatesh M Deshpande 2014년 3월 23일
Hello, Can anybody help me? I want to figure out where I am doing a mistake in program. The only variable is X and Cp is an input.
Cp = double(zeros(49792,1));
P = size(x.Time_Series);
Q = P(1,1);
Cp(1,1)= 0.126826003999670;
Cp(2,1)= 0.325943036562508;
for k=3:Q;
k
hx = inline( '12.175*(X - 2*Cp(k-1,1) + Cp(k-2,1)) + 13.525*((X - Cp(k-1,1))* abs(X - Cp(k-1,1))) + X - SINGLE_FINAL_TIME_SERIES_OF_TAPS_NEAR_DOMINANT_OPENING(k,1)','X',Cp);
hp = fzero (hx,0,Cp,SINGLE_FINAL_TIME_SERIES_OF_TAPS_NEAR_DOMINANT_OPENING(k,1));
Cp(k) = hp(1);
end
I am getting this error
Error: The expression to the left of the equals sign is not a valid target for an
assignment.
If in inline function, I remove Cp which is given after X (at the very last near the bracket), then it shows error: too many inputs to inline function. Pls help. thanks.

채택된 답변

Star Strider
Star Strider 2014년 3월 20일
It doesn’t like the ‘==’ in SINGLE_FINAL_TIME_SERIES_OF_TAPS_NEAR_DOMINANT_OPENING(k,1)==0.
Unlike anonymous functions that use workspace variables, inline functions ignore anything that isn’t in their argument list. It has no idea what SINGLE_FINAL_TIME_SERIES_OF_TAPS_NEAR_DOMINANT_OPENING(k,1) or k are.
Also, fzero only accepts single-variable functions.
  댓글 수: 9
Star Strider
Star Strider 2014년 3월 23일
My pleasure!
Wow! And a tribute, too! Thank you!
I have a background in physical chemistry and am an instrument-rated private pilot, so I'm slightly familiar with what you are doing. I do not have sufficient background in fluid dynamics to understand it in any detail, though.
Venkatesh M Deshpande
Venkatesh M Deshpande 2014년 3월 23일
Thanks for helping and telling about your background. Take care.

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

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2014년 3월 20일
Avoid using inline, instead use an anonymous function

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by