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
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by