フィルターのクリア

How to mirror a 3D plot in same coordinates?

7 ビュー (過去 30 日間)
vilas math
vilas math 2021 年 5 月 23 日
回答済み: Tejas 2024 年 2 月 22 日
clear
clc
m = 100 ; n = 100 ;
zv = linspace(-1,1,m);
phiv = linspace(0,2*pi,n);
[zv, phiv] = meshgrid(zv,phiv);
rv = ones(size(zv))*1;
% Used the gaussian formula
%rv2 = -0.8*exp(-1.2*(phiv-4).^2)+1;
% Meshing(Question?)
%[Theta, R] = meshgrid(phiv,rv);
L = linspace(-0,0.5,50);
L=[L fliplr(L)];
zb1 = zeros(m,n,length(L)) ;
% checking the geometry in Z-direction by value "f"
phiv_loc = phiv(:,1); % take 1st column
for i = 1:length(L)
f=L(i);
rv3(:,i) = -f*exp(-1.2*(phiv_loc-4).^2)+1;
end
%mesh(Theta,R,zv)
% figure(1)
% plot3(phiv,rv,zv)
% hold on
% plot3(phiv,rv2,zv)
% hold on
% plot3(phiv,rv,zb1(:,:,1))
% axis equal
% Converting polar to cartesian cordinates in (x,y,z) direction
[x,y,z] = pol2cart(phiv,rv,zv);
%[x2,y2,z2] = pol2cart(phiv,rv2,zv);
[x3,y3,z3] = pol2cart(phiv,rv3,zv);
% Coverting Pol2cart inside the loop
%[x3,y3,z3] = pol2cart(phiv,rv,zb1);
figure(2)
%plot3(x,y,z)
%hold on
surf(x3,y3,z3)
%hold on
%plot3(x3,y3,z3(:,1))
axis equal
ax = gca;
%set(gca,'xdir','reverse')
flip(figure(2),2)

回答 (1 件)

Tejas
Tejas 2024 年 2 月 22 日
Hello Vilas,
I am assuming that by “mirror of a 3-D plot”, you meant mirror of plot along some axis.
Below is an example of how negating the coordinates of an axis creates a mirror image of plot along that axis. I have created two plots, first plot to show the original plot and second plot to show the mirror of that plot along y-axis.
m = 100; n = 100;
zv = linspace(-1,1,m);
phiv = linspace(0,2*pi,n);
[zv, phiv] = meshgrid(zv,phiv);
rv = ones(size(zv))*1;
L = linspace(-0,0.5,50);
L = [L fliplr(L)];
zb1 = zeros(m,n,length(L));
phiv_loc = phiv(:,1);
rv3 = zeros(size(zv,1), length(L));
for i = 1:length(L)
f = L(i);
rv3(:,i) = -f*exp(-1.2*(phiv_loc-4).^2)+1;
end
[x,y,z] = pol2cart(phiv,rv,zv);
[x3,y3,z3] = pol2cart(phiv,rv3,zv);
figure(1)
surf(x3,y3,z3)
axis equal
xlabel('X-axis')
ylabel('Y-axis')
zlabel('Z-axis')
title('Original 3D Plot')
figure(2)
surf(x3,-y3,z3)
axis equal
xlabel('X-axis')
ylabel('Y-axis')
zlabel('Z-axis')
title('Mirrored 3D Plot along y-axis')
Below is Screen Shots of the desired output :
For more information on negation of vector, refer this documentation :
Hope it helps!

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by