Excel SUM IF in MATLAB?

11 visualizaciones (últimos 30 días)
Jared
Jared el 23 de Mzo. de 2014
Respondida: Image Analyst el 23 de Mzo. de 2014
Hi all,
I'm going through a trial period of MATLAB and almost certainly will end up purchasing it, but I had one specific functionality question related to SUMIF tasks that I frequently use in Excel. If I have an Excel file with columns of both numerical data and text how in MATLAB would I perform SUMIF related calculations on that data?
As a concrete example let's say I have numerical data in the range A1:A1000 in Excel and text data representing state abbreviations ("TN", "MO", "CA", etc) in the range B1:B1000 in Excel. In Excel I could easily create a formula to sum all the numerical values when column B values equal "TN" or equal "TN" and "MO". How would I do this in MATLAB?
Also, the main reason I'm interested in doing these types of calcs in MATLAB instead of Excel is because I'm dealing with increasing large blocks of data in Excel and increasingly complex SUMIF calculations that are bogging down my spreadsheets.
Thanks,
JK

Respuestas (1)

Image Analyst
Image Analyst el 23 de Mzo. de 2014
You can use functions like strcmpi(), strfind(), etc. Then you can use if/else blocks or swtich blocks to do things based on which case you find.

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by