필터 지우기
필터 지우기

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.
Andrew Padilla
Andrew Padilla 2018년 9월 16일
Thank you for pointing that out. I will make sure to fix that! I also appreciate the hint! It helped out quite a lot.

댓글을 달려면 로그인하십시오.

답변 (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