# Construct quarter circle of data in matrix

조회 수: 7 (최근 30일)
Roel . 2018년 5월 16일
댓글: Roel . 2018년 5월 16일
Hello everyone,
I have a 5000x1 vector P. I would like to make a 5000x5000 matrix where the values of P fill the matrix as if P is dragged clockwise, as shown below:
(As you can see my MS paint skills exceed my matlab skills.)
I don't know how to deal with the circular shape. I see how it is not possible to fit a perfect circle into a matrix, but an approximation will do. How would one go about making a good approximation of the desired matrix?

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

### 채택된 답변

sloppydisk 2018년 5월 16일
편집: sloppydisk 님. 2018년 5월 16일
I would do it like this:
n = 5000;
P = [randi(n, n, 1); zeros(n, 1)];
[X, Y] = meshgrid(1:n, flip(1:n));
r = round(sqrt(X.^2 + Y.^2));
A = reshape(P(r(:)), n, n);
First I wrote
A = arrayfun(@(x) P(x), r);
but that's stupidly slow of course.
##### 댓글 수: 1없음 표시없음 숨기기
Roel 2018년 5월 16일
Thank you!

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

### 카테고리

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

### Community Treasure Hunt

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

Start Hunting!

Translated by