Write values in new matrix and mirror values with symmetry axis

3 views (last 30 days)
wswur
wswur on 16 Jun 2017
Answered: Ankita Nargundkar on 22 Jun 2017
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

Answers (1)

Ankita Nargundkar
Ankita Nargundkar on 22 Jun 2017
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

Community Treasure Hunt

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

Start Hunting!