extract value of random matrix

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.

Réponses (1)

Image Analyst
Image Analyst le 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 commentaires

vachelard Valentin
vachelard Valentin le 21 Mar 2015
I don't have this toolbox :/
I will check that
thx!!
Image Analyst
Image Analyst le 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Financial Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by