Write values in new matrix and mirror values with symmetry axis

5 次查看(过去 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

回答(1 个)

Ankita Nargundkar
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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by