필터 지우기
필터 지우기

Replace values in a array

조회 수: 5 (최근 30일)
Miguel Albuquerque
Miguel Albuquerque 2022년 7월 18일
댓글: Miguel Albuquerque 2022년 7월 18일
Hey guys, thanks in advance, this is probably very easy
What I need to do, is find where y_max is not zero, and see where the values from it are equal to range, a bigger array, but that has in some columns the same values of y_max.
Next I need to replace the columns where range has the same values of y_max by the values of RMC that are not zero.
How can I do that, thanks. Because its mandatory that all columns of b be replaced by isR2, but isR2 has more values that b, but for isR2 i want to select number os values of b, because RMC has the same values along the array.
I have this code:
isR=find(y_max);
isR2=find(RMC);
y_cutted=y_max(isR);
[a,b]=intersect(range,y_cutted);
b=b.';
range(:,b)=RMC(:,isR2);
But i get this error
Unable to perform assignment because the size of the left side is 1-by-69 and the size of the right side is 1-by-93.
  댓글 수: 1
Miguel Albuquerque
Miguel Albuquerque 2022년 7월 18일
basically I need to do this, but automatic:
isR=find(y_max);
y_cutted=y_max(isR);
[a,b]=intersect(range,y_cutted);
b=b.';
RMC=RMC(:,184:255);
range(:,(254:325))=RMC;

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

답변 (1개)

David Hill
David Hill 2022년 7월 18일
Attaching the data would help.
range(ismember(range,y_max(y_max~=0)))=RMC(RMC~=0);
  댓글 수: 1
Miguel Albuquerque
Miguel Albuquerque 2022년 7월 18일
sorry, here it is , it gives an error your code
Unable to perform assignment because the left and right sides have a different number of elements.

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

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by