How do I reflex a plot?

2 次查看(过去 30 天)
Mikel Gonzalez Bribiesca
回答: Star Strider 2021-11-24
Okay so I got the next code which displays the graph shown below.
It is the code for potential and field lines in a capacitor, or in this case, for the right side of the capacitor.
How can I plot it for it to show both left and right side? So the same lines would show on both sides.
Thank you so much
u = -8:1:1.3;
for v = -pi:pi/10:pi
x = 1 + u + exp(u)*cos(v);
y = v + exp(u)*sin(v);
plot(x,y,'r')
hold on
end
hold on
v2 = -pi:pi/100:pi ;
for u2 = -8:.25:1.3
x = 1 + u2 + exp(u2)*cos(v2);
y = v2 + exp(u2) * sin(v2);
plot(x,y,'b')
hold on
end

回答(1 个)

Star Strider
Star Strider 2021-11-24
Try this —
u = -8:1:1.3;
v = -pi:pi/10:pi;
for k = 1:numel(v)
x{k,1} = 1 + u + exp(u)*cos(v(k));
y{k,1} = v(k) + exp(u)*sin(v(k));
plot(x{k,1},y{k,1},'r')
hold on
end
hold on
v2 = -pi:pi/100:pi ;
u2 = -8:.25:1.3;
for k = 1:numel(u2)
x{k,2} = 1 + u2(k) + exp(u2(k))*cos(v2);
y{k,2} = v2 + exp(u2(k)) * sin(v2);
plot(x{k,2},y{k,2},'b')
hold on
end
maxx = max(cellfun(@(x)max(x(:)),x(:,2))); % Add Or Subtract From This Value To Adjust Spacing
x1r = 2*maxx - cell2mat(x(:,1));
y1r = cell2mat(y(:,1));
x2r = 2*maxx - cell2mat(x(:,2));
y2r = cell2mat(y(:,2));
plot(x1r.', y1r.', '-r')
plot(x2r.', y2r.', '-b')
hold off
.

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by