Excel SUM IF in MATLAB?

조회 수: 8 (최근 30일)
Jared
Jared 2014년 3월 23일
답변: Image Analyst 2014년 3월 23일
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

답변 (1개)

Image Analyst
Image Analyst 2014년 3월 23일
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.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by