Write values in new matrix and mirror values with symmetry axis
조회 수: 3 (최근 30일)
이전 댓글 표시
This is the case: In an script (not shown here) I generate a quadrant of an ellipse in a matrix, filled up with values (to create a 3D shape). I try to mirror this quadrant in a new matrix to obtain the complete ellipse, based on symmetry axis. Below my script is shown, but I don’t get it completely working. The only thing that works is copying the quadrant shape to the new matrix, starting in the centre of that matrix instead of position (1,1) as the original matrix does. But the quadrant gets copied with a single values, while instead the original quadrant exists of multiple different values. The first part scans the original matrix with the quadrant starting in position (1,1) and copies the values to a new matrix.
I hope someone can help me out!
for ii = 1:length(sigma_contact(:,A)) %old matrix
for jj = 1: length(sigma_contact(B,:)) %old matrix
if sigma_contact(round(ii),round(jj)) > 0
for x = 50 : length(complete_ellipse(1,:))
for y = 50 : length(complete_ellipse(1,:))
complete_ellipse(x,y) = sigma_contact(ii,jj) ; %swrite matrix values in new matrix
end
end
else
%do nothing / next row
end
end
end
for i = A:length(complete_ellipse(A,:)) %till symmetry axis
for j = B: length(complete_ellipse(B,:)) %till symmetry axis
for x = 1:A %begin in row till A
for y = B:length(complete_ellipse(B,:)) %from row B till end
complete_ellipse(x,y) = complete_ellipse(ii,jj) %left lower quadrant
complete_ellipse((A-x),(B-y)) = complete_ellipse(ii,jj) %left upper quadrant
end
end
%right upper quadrant
for x = 1:A
for y = 1:B
complete_ellipse(x,y) = complete_ellipse(i,j)
end
end
end
end
댓글 수: 0
답변 (1개)
Ankita Nargundkar
2017년 6월 22일
If you can find the center you can replicate it easily, Also try to find the equation. Also if you have curve fitting toolbox u can use it to fill the ellipse
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!