how can I delete a full row based on a if condition?

1 回表示 (過去 30 日間)
Locks
Locks 2013 年 3 月 10 日
for example if I have a matrix with call (1) and putoption (2) data and I would like to have only the calloption data. Iwas thinking maybe I could run a for condition and create a new matrix just using the call data, is that possible?

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 10 日
Yes, that is one option. Another is (e.g.)
idx = (profit < 0);
funds(idx,:) = [];
  1 件のコメント
Locks
Locks 2013 年 3 月 10 日
I am still not sure how does should work. For example, I have the following matrix: 1270.35 1110 2 0.5250 0.052 734506 0.0026425 1270.35 1115 2 0.5500 0.052 734506 0.0026425 1270.35 1120 2 0.5750 0.052 734506 0.0026425 1270.35 1125 2 0.600 0.052 734506 0.0026425 1270.35 1130 2 0.700 0.052 734506 0.0026425 1270.35 1135 2 0.8500 0.052 734506 0.0026425 1270.35 1165 1 107 0.052 0.0026 0.0026425
an so on
first column: future price 2nd column: strike 3rd: 2=put, 1=call 4th: option price 5th: time to maturity 6th: date 7th: interest rate
the total matrix consist of 150'000 columns of call and put optiondata, how can I create a matrix out of this with just the data of the put options? and how can I create another one with just the call option data?
thanks for your help!

サインインしてコメントする。

その他の回答 (3 件)

Locks
Locks 2013 年 3 月 10 日
編集済み: Walter Roberson 2013 年 3 月 10 日
I am still not sure how does should work. For example, I have the following matrix:
1270.35 1110 2 0.5250 0.052 734506 0.0026425
1270.35 1115 2 0.5500 0.052 734506 0.0026425
1270.35 1120 2 0.5750 0.052 734506 0.0026425
1270.35 1125 2 0.600 0.052 734506 0.0026425
1270.35 1130 2 0.700 0.052 734506 0.0026425
1270.35 1135 2 0.8500 0.052 734506 0.0026425
1270.35 1165 1 107 0.052 0.0026 0.0026425
an so on
first column: future price 2nd column: strike 3rd: 2=put, 1=call 4th: option price 5th: time to maturity 6th: date 7th: interest rate
the total matrix consist of 150'000 columns of call and put optiondata, how can I create a matrix out of this with just the data of the put options? and how can I create another one with just the call option data?
thanks for your help!

Cedric
Cedric 2013 年 3 月 10 日
編集済み: Cedric 2013 年 3 月 10 日
If your data is stored in a 150000x7 matrix D, you can build D_call and D_put as follows:
D_call = D(D(:,3)==1,:) ;
D_put = D(D(:,3)==2,:) ;

Locks
Locks 2013 年 3 月 10 日
great, thats working! thank you very much
  3 件のコメント
Jan
Jan 2013 年 3 月 18 日
@Sven: You do not have to accept an answer, but it would be helpful for the readers and for the author of the answer. So please take the time to accept an answer, such that this question is marked as "solved".
Cedric
Cedric 2013 年 3 月 18 日
Thank you Azzi and Jan; I stopped making this kind of remarks, but I should have gone on. I appreciate that you took the time to do it!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePrice and Analyze Financial Instruments についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by