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 Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by