How to replace values of a logical index with values from another matrix if certain conditions are met?
1 view (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 16 Sep 2018
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.
Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!