More efficient Matlab code to assign the nth iteration a line combination appears in the table (looking from top to bottom)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm looking for a more efficient way to create a column in my table of stock options that assigns the nth value it has appeared in that table so far, moving from top to bottom.
First, I can show you want I'm talking about using the logic I have in Excel to create a Key that assigns the iteration a stock with an options contract x business days until expiration (BDTE) appears, using a key "BDTE" - "Iteration." In the Excel formula, it takes the total frequency of a given BDTE for an Underlying Symbol (TSLA in this case), and subtracts the number of times that same Ticker / BDTE combo appears in the rest of the table.
In Matlab, I tried using Parfor to create the iterations, but this code snippet takes ages to run, like 40 min, when the rest of my code takes like 5 minutes. Do you have any suggestions on logic to make this code more efficient?
count_call = zeros(call_height,1);
parfor h = 1:height(call_summary)
count_call(h) = sum((call_summary.UnderlyingSymbol == call_summary{h,'UnderlyingSymbol'}).*(call_summary.BDTE == call_summary{h,'BDTE'}).*(call_summary.DataDate >= call_summary{h,'DataDate'}));
end
call_summary(call_array,'Key1') = array2table(strcat(string(call_summary{call_array,'BDTE'}),'-',string(count_call(call_array,1))));
Thank you in advance for any ideas you have!
1 comentario
dpb
el 25 de Oct. de 2022
First idea is that we'll need to have a set of the data to work from and then a definition of what you're actually trying to do. We can't do nuthin' with just an image to look at and nobody's going to try to figure out what is going on from just such a isolated code snippet, sorry...
Respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Functions in Microsoft Excel en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!