How do I reflex a plot?

3 views (last 30 days)
Mikel Gonzalez Bribiesca
Mikel Gonzalez Bribiesca on 24 Nov 2021
Answered: Star Strider on 24 Nov 2021
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

Answers (1)

Star Strider
Star Strider on 24 Nov 2021
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
.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!