How to compare previous column values of all rows to the current column value with a user defined criteria

조회 수: 2 (최근 30일)
Hello MATLAB Experts,,
i am stuck at a problem.. please help in solving this..
the Question is:-
i have a matrix A = 2x6. Now, i want to append to it 8 more rows to make it 10x6 .. to do this, for the first 4 columns i am sampling using randi in range [20,100]. i want sampled value for each column in a way (abs(sampled_value-all_previous_row_values_of_same_column)/100-20)>15. that means i want to compare the current sampled value of a collumn with all the previous row values of same column using the criteria written in bold. we will consider the sampled value only if satisfies criteria for all previous row values .. similarly i want to do for next 3 columns. if all 4 columns satisfies the criteria, we will add the rest 2 columns(5 and 6) to the new row as it is.and add the created row to the matrix A.
please help me in doing this..
Thank You in advance
  댓글 수: 2
Image Analyst
Image Analyst 2022년 10월 10일
I don't know exactly how you'd do "abs(sampled_value-all_previous_row_values_of_same_column)". Can you provide an actual example with actual numbers?
Rohit P
Rohit P 2022년 10월 12일
i figured out the answer using bsxfun.. Thank You for taking out time to answer the question..appreciate it..

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by