How to alter nearby values in a matrix with respect to a column?

조회 수: 3 (최근 30일)
Hems
Hems 2018년 4월 13일
댓글: Hems 2018년 4월 13일
Hi, I have a 2D matrix A(1:100,1:100), and I replaced one of its column (A(1:100,50)) with another column vector Y(1:100,1). Now I want the nearby columns in A to vary gradually with respect to the values in Y. Is it possible to do this in matlab? Thanks.
  댓글 수: 2
Bob Thompson
Bob Thompson 2018년 4월 13일
What do you mean by "vary gradually with respect to the values in Y"? What kind of variance are you looking for? It is entirely possible to adjust the values of A with respect to the new values from Y, but the how is dependent on the type of variance you're looking to perform.
Hems
Hems 2018년 4월 13일
Thanks for your answer. After I replaced a column of my matrix, I can see an abrupt change in the values on either side of the replaced column, when I plot it as an image. For my purpose it doesn't matter what type of variance it is, as long as there is no abrupt change in the 2D image. Thanks.

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

채택된 답변

Jan
Jan 2018년 4월 13일
A = rand(10, 10); % smaller test data
A(:, 5) = 10 * rand(10, 1);
A(:, 4) = (A(:, 5) + A(:, 4)) / 2;
A(:, 6) = (A(:, 5) + A(:, 6)) / 2;
A(:, 3) = (A(:, 5) + 2 * A(:, 3)) / 3;
A(:, 7) = (A(:, 5) + 2 * A(:, 7)) / 3;
Now the direct neighbors contain the mean between the inserted column and the original data, while the 2nd neighbors contain the weighted mean.
There is an infinite number of other ways for a gradual variation. So please explain, what you exactly need.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by