How to replace values of a logical index with values from another matrix if certain conditions are met?
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix labeled "A" [daily values] with the following values [10, 15, 30]
where 10 is a minimum temperature, 15 is an average temperature, and 30 is a maximum temperature
I also have a matrix labeled "B" [long term values] with the values [9, 12, 18; 11, 16 14; 14, 17, 19; 13, 14, 17] where the first column represents minimum temperatures, the second column represents average temperatures, and the third column represents maximum temperatures.
I am assigned the following task:
Determine if any of the minimum values in the daily term values array are less than any of the minimum values in the long term values array. Create a matrix that lists all the values in a column, that are less than the long term values. The second column should contain the day at which these values occurred. (each row of matrix A and B is a day. Day 1 = row 1).
I have tried everything, but I can not seem to accomplish this task.
6 个评论
Walter Roberson
2018-9-16
Okay, that looks better.
I would suggest, though, that when a problem is worded in terms of "less than" that it makes the most sense to use a < operator than to use a > operator. This would involve switching the two operands involved.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!