Shifting column with data

조회 수: 3 (최근 30일)
SugerCodeCude
SugerCodeCude 2019년 7월 4일
댓글: SugerCodeCude 2019년 7월 4일
From the picture I would like to move everything from the column 2 between 120(degree) and 240(degrees), shifted one time to the left and shifted down one more time. Next, for column 3 between 240 (degree) and 360(degree), shift two times to the left and two times down.
Below is the code to the graph from the picture. I am not sure how to proceed. If you need clarification I can do so.
for i = 1:N
if (TFx(i) == 0) && (TFy(i) == 0)
if (sOnAngleH0(i)>=xBotEdge && sOnAngleH0(i)<=xTopEdge...
&& AngleHa(i)>=yBotEdge && AngleHa(i)<=yTopEdge)
xi = ceil((sOnAngleH0(i)-xBotEdge)/[(xTopEdge - xBotEdge)/row]);
yj = ceil((AngleHa(i)-yBotEdge)/[(yTopEdge - yBotEdge)/col]);
jointBins(xi, yj) = jointBins(xi, yj) + 1;
end
end
end
Any help is most appreciated.
P.S. I need the data of the columns being shift to overlay on the other data points, after all the columns shift all the diagonal points all to be in 0 < x < 120 and 0 < y < 120.

채택된 답변

KSSV
KSSV 2019년 7월 4일
YOu may proceed some thinkg like this:
[X,Y] = meshgrid(1:10,1:10) ;
Z = diag(1:9,-1)+diag(1:10)+diag(1:9,1) ;
Z = fliplr(Z) ;
figure(1)
pcolor(X,Y,Z)
% to move this chunk
[X1,Y1] = meshgrid(4:7,4:7) ;
Z1 = interp2(X,Y,Z,X1,Y1) ;
% to this chunk
[X2,Y2] = meshgrid(1:4,1:4) ;
Z2 = Z ;
Z2(1:4,1:4) = Z1 ;
figure(2)
pcolor(X,Y,Z2)
  댓글 수: 2
SugerCodeCude
SugerCodeCude 2019년 7월 4일
Thank you for you quick response,
I am testing the code you have provied, when I shift this it overlay the data or does it change and it replaces it with what has been shifted?
KSSV
KSSV 2019년 7월 4일
Run the code and analysie it....I have replaced there....you can make necessary changes.

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

추가 답변 (1개)

SugerCodeCude
SugerCodeCude 2019년 7월 4일
The code works great, however I put in my jointBins and in a area to then move. I get a error
% to move this chunk
[X1,Y1] = jointBins(4:7,4:7) ;
because it is 10x10, error is
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
in my code the row = 10 and col = 10
and
xTopEdge = 360
xBotEdge = 0
yTopEdge = 360
yBotEdge = 0
  댓글 수: 2
KSSV
KSSV 2019년 7월 4일
Your data will be:
x = linspace(0,360,10) ;
y = linspace(0,360,10) ;
[X,Y] = meshgrid(x,y) ;
SugerCodeCude
SugerCodeCude 2019년 7월 4일
Thank you for all you help!

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by