필터 지우기
필터 지우기

2D Matrix operations and assigning max values

조회 수: 1 (최근 30일)
JIAN-HONG YE ZHU
JIAN-HONG YE ZHU 2022년 12월 14일
편집: Santosh Fatale 2022년 12월 20일
Hello, I have a 390891x3 matrix and I want to do the following. The first and third column are rounded to one decimal place. The first column is multiplied by 100 and the third column by 10. Then these two are added. This new number then is assigned to the maximum or minimum value of the second column and the original value is reverted (when the 1st and 3rd column value was combined. The minimum or maximum is the criteria because there might be multiple numbers after the combination that are duplicate. Here is an example of what I mean:
1.34731352329254 -1.31217169761658 2.37200021743774
1.35286617279053 -1.11217169761658 2.37200021743774
1.33170139789581 -1.10774617195129 2.36400008201599
1.33723533153534 -1.30774617195129 2.36400008201599
1.3 -1.3 2.4
1.4 -1.1 2.4
1.3 -1.1 2.4
1.3 -1.3 2.4
1324 assigned to -1.1 %1300+24
1424 assigned to -1.1 %1400+24
Matrix afterwards:
1.3 -1.1 2.4
1.4 -1.1 2.4
One of the issues I came up with is that the 1st column might have negative values, I made a matrix with the index position of values in the 1st column with negative values and a matrix with the index position of positive values in the 1st column.
I also know how to do the other basic calculations, the thing I am not sure is how to assign the maximum or minimum value of the second column to the merged number (combined from the 1st and 3rd column). Would I be using the unique function?
Thank you very much. Let me know if I did not explain myself clearly.
  댓글 수: 4
Fabio Freschi
Fabio Freschi 2022년 12월 15일
I guess the first column is multiplied by 1000. Then it is not clear what you want to do with 1000*c1+10*c2, since "Matrix afterwards" section of your message there is no presence of 1324 and 1424
Santosh Fatale
Santosh Fatale 2022년 12월 19일
편집: Santosh Fatale 2022년 12월 20일
Hi Jian-Hong,
As @Fabio Freschi mentioned, you multiplied column1 by 1000 (and not by 100) and multiplied column2 by 10. After colum addidtion, you will get a columnn. I am not sure how you are getting scalar value.
Following things are not clear:
  • "This new number then is assigned to the maximum or minimum value of the second column and the original value is reverted (when the 1st and 3rd column value was combined."
What do you mean by assigned to minimum or maximum value of second column? Do you mena to replace the minimum or maximum value of the column 2 with this new value?
  • "I am not sure is how to assign the maximum or minimum value of the second column to the merged number (combined from the 1st and 3rd column)."
What do you mean by assigning a value of the second column to the number?
Provide some toy exapmple without repition of entries in matrix. The proper example could help us to provide correct and speedy solution.

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

답변 (0개)

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by