|
"Diego Zegarra" <diegozbb@gmail.com> wrote in message
news:glioo6$srl$1@fred.mathworks.com...
>I just have a quick question,
>
> if h = [121 Inf 125 175 141 176]
>
> What is this line of text going to do?
>
> MaxTimeL = max(max(h(isfinite(h)),1));
>
> What value is MaxTimeL obtaining? Is it 176?
>
> I am trying to look for the maximum finite number in h. Please let me know
> if this line of code is correct or not.
When trying to figure out what code is doing, usually you want to start from
the inside out.
Do you know what "isfinite(h)" does? If not, look at "help isfinite".
Once you know what "isfinite(h)" does, do you know what "h(isfinite(h))"
does? If not, try it out and take a guess, and then search for "logical
indexing" in the help. [Knowing to look for "logical indexing" is a bit of
a jump, but if you didn't know about logical indexing I would expect you to
ask specifically what "h(isfinite(h))" does, and then someone would point
you to logical indexing.]
Once you know what "h(isfinite(h))" does, do you know what
"max(h(isfinite(h)), 1)" does? If not, look at "help max".
Now, given that you know what "max(h(isfinite(h)), 1)" does, do you know
what the full expression does?
--
Steve Lord
slord@mathworks.com
|