IF statement inside a function called via rowfun.

1 view (last 30 days)
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 Comments
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi on 17 Apr 2020
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 on 27 Apr 2020
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.

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!