Reading a table and finding a specific value that corresponds to another
1 回表示 (過去 30 日間)
古いコメントを表示
J Morgan Alsbrook
2019 年 11 月 29 日
コメント済み: Walter Roberson
2019 年 11 月 29 日
I am trying to write a .m script so that it imports a excel file and compares the data that I enter to the imported table. Column 1 of the table is 1A,1B 2A, 2B. Column 2 of the table is the GPA. What I am trying to do is input an academic class and current gpa and I want it to go to the table and find that academic class and avg all the gpa's next to those academic classes and assign it to a variable. For some reason I cannot get the find command to work. Attached is my code and outputs seen in Matlab.
0 件のコメント
採用された回答
Walter Roberson
2019 年 11 月 29 日
find( strcmp(grades{:,1}, answer{1}) )
2 件のコメント
Walter Roberson
2019 年 11 月 29 日
mask = strcmp(grades{:,1}, answer{1});
retrieved_gpa = grades{mask, 2};
If you prefer to stick with find() instead of logical masks then
rownum = find(strcmp(grades{:,1}, answer{1}));
retrieved_gpa = grades{rownum, 2};
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!