Find minimum difference in arrays from exact value
古いコメントを表示
Hi!
I have option strike prices (Strike), date, and price index correspond to date.
I need to find the strike value (from Strike column) which is the nearest to Price for correspond day.
For example: The nearest price of 5848 for 05.02.2016 date is 5850.
The nearest price of 5689 for 08.02.2016 date is 5675.
The data is attached in excel file.
I should have only one Strike (column 1) price which is the nearest to the Price (column 3) for each date.
One simple table in the output, such as:
05.02 - one price,
08.02 - one price,
09.02- one price and so on.
Can you help me please how to solve this in MATLAB?
Thanks a lot
2 件のコメント
YT
2019 年 2 月 3 日
What have you tried yourself already (please provide some code)? It's not a difficult problem, so are stuck on how to solve it or do you have trouble with coding it yourself?
Artem Bielykh
2019 年 2 月 3 日
採用された回答
その他の回答 (1 件)
Image Analyst
2019 年 2 月 3 日
Subtract and then use min():
priceDifferences = strikePrice - dailyPrice;
[minDiff, indexOfMin] = min(priceDifferences);
strikeValue = strikePrice(indexOfMin)
カテゴリ
ヘルプ センター および File Exchange で Time Series Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!