extract value of random matrix
Show older comments
Hello everyone,
I face a problem and I can not find a way to solve it. My problem is the following:
I simulate a geometric Brownian and an exponential barrier. I am looking to extract the time of contact between my fence and my Brownian. I manage to get a matrix that takes the value 0 if my Brownian is superior and the value of time otherwise. And I would like to extract each value that is after a 0 and a 0 before each value. [0 0 0 1 2 3 4 5 0 0 0 6 0] I would like to extract 1 5 and 6 On a path I can do it with "find" but the idea that I reply I do not see how.
if someone has an idea thank you.
Answers (1)
Image Analyst
on 21 Mar 2015
0 votes
Trivial if you have the Image Processing Toolbox - do you? Otherwise use abs(diff(vector))) with some other code to make sure you don't get uniform areas inside the non-zero areas.
2 Comments
vachelard Valentin
on 21 Mar 2015
Image Analyst
on 21 Mar 2015
Too bad. Type "ver" on the command line to make sure you don't see it. Using diff() will be a lot more complicated if it's robust enough to handle all the strange cases you might encounter.
Categories
Find more on Financial Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!