IF statement inside a function called via rowfun.

조회 수: 1 (최근 30일)
Roger Gomila
Roger Gomila 2020년 4월 14일
댓글: Peter Perkins 2020년 4월 27일
I have some timetables in which I want to apply a function in which the following code is written:
Z = 182.13;
if any(Re_h > Z, 'all')
psi_h = (Re_h ./ Z).^(-0.15.*sind(57.6));
elseif any(Re_h < Z, 'all')
psi_h = 1;
end
the problem I am facing is that I don't understand why it never enters the elseif statement although the Re_h is less than Z. No matter which value the Re_h is that it will execute the first statement.
I first tried this way but did not work as well:
if Re_h > Z
psi_h = (Re_h ./ Z).^(-0.15.*sind(57.6));
else
psi_h = 1;
end
I think the problem might be with the table row execution I think, but I don't know how to do it and I wondered if somebody could help me.
Thanks.
  댓글 수: 3
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020년 4월 17일
Hi Roger,
I believe that the variable Re_h is important to solving the issue you're facing. As mentioned by @Peng, sharing the code that you use to get the of value(s) of Re_h might be helpful to solve the issue.
Further, even if at least one of the values of the vector Re_h is a value greater than z, the first block of your code fails. Next, the second block of your code failing indicates that all the element(s) within Re_h are in greater than z. This is a peculiar case.
Peter Perkins
Peter Perkins 2020년 4월 27일
Roger, you need to show a small example of what your timetable looks like (as others have said), as well as the entire function you are applying, as well as the call to rowfun. Noone can help you with those.

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

답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by