Finding category/string in table and converting values
5 次查看(过去 30 天)
显示 更早的评论
Alright so I'm having trouble knowing how to write a script to convert values.
Basically, I want to 1) Read in a file or Access a table 2) Find all the instances in the rows of the table with the string "CBEAM" 3) In said row, go to the 4th column and multiply that number by 0.5 4) Find all instances in the rows of the table with the string "CQUADR" 5) In said row, go to the 6th column and multiply that number by 0.6
So I can envision lots of if, then statements, which is totally fine. But I really don't know how to get started or what to write at all. Can anyone help
0 个评论
采纳的回答
Peter Perkins
2018-2-21
Don't do that. Assume T is your data stored in a table containing a categtorical variable named SomeVarName whose categories are 'CBEAM' 'CQUADR', ... . Then
i = (T.SomeVarName == 'CBEAM');
T.SixthVarName(i) = .5 * T.SixthVarName(i);
etc.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!