Searching for multiple conditions in a large array
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
if ( strcmp(f(j,1),'OPTSTK') && strcmp(C(j,2),stock) && ((datenum(C(j,3),'mm/dd/yyyy')-Earnings_Date)>5 && (datenum(C(j,3),'mm/dd/yyyy')-Earnings_Date)<25 && found==0 && B(j,8)>5) && (Earnings_Date-(datenum(Date_1,'dd-mmm-yyyy')+L)>5))
Hi folks, I am working with a large set of files, each that have several thousands rows each. THe number of columns are constant so that helps. I have a few conditions on some of the colums. Which when all satisfied yield a unique row. What's the most efficent way of finding this? I have been strcmp, but takes quite some time to pull the result. I am bit rusty as I haven't MATLAB in many years.
I am searching if Coulmn1==A && Column2==B && Column3==C.
Cheers!
9 comentarios
Adam Danz
el 14 de Jul. de 2020
Indexing is different for tables. Here's everything you need to know about accessing and indexing table data. The table at the top of the page summarizes everything.
For example, instead of
strcmp(f(j,1),'OPTSTK')
use
strcmp(f{j,1},'OPTSTK') % where f is your table
or you can use the header values (aka 'variable names')
strcmp(f.Var1(j),'OPTSTK') % where f is your table and Var1 is the header for column 1
Respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!