Can we rotate the plot(x, y)

3 views (last 30 days)
CHANDRABHAN Singh
CHANDRABHAN Singh on 23 Sep 2021
Answered: Cris LaPierre on 23 Sep 2021
for w=0.5:0.1:1
l = w;
thet = 0:1:60;
theta = thet .*(pi/180);
c = cos(theta);
p = 4*(1-l^2).*(c.^2) + (2*l - 1)^2;
q = 2*(1-l*l).*c + (2*l-1)*sqrt(4*(1-l*l).*(c.^2) + 5 *l*l - 4*l);
r =(q./p);
thetaa = [0:60, 60:120, 120:180, 180:240, 240:300, 300:360].*(pi/180);
v = [r, fliplr(r(1:61)), r(1:61), fliplr(r(1:61)), r(1:61), fliplr(r(01:61))];
%polarplot(thetaa,v);
[x, y] = pol2cart(thetaa, v);
plot(x,y);
hold on;
end
pbaspect([1 1 1]);
grid on;
xlabel('x-axis');
ylabel('y-axis');
If we run the above code, the following plot is obtained. I want the apex to be pointed upwards (any apex of the tringle). Is it possible.

Accepted Answer

Cris LaPierre
Cris LaPierre on 23 Sep 2021
You could reverse your x and y inputs. Use -x to make the triangle point up.
for w=0.5:0.1:1
l = w;
thet = 0:1:60;
theta = thet .*(pi/180);
c = cos(theta);
p = 4*(1-l^2).*(c.^2) + (2*l - 1)^2;
q = 2*(1-l*l).*c + (2*l-1)*sqrt(4*(1-l*l).*(c.^2) + 5 *l*l - 4*l);
r =(q./p);
thetaa = [0:60, 60:120, 120:180, 180:240, 240:300, 300:360].*(pi/180);
v = [r, fliplr(r(1:61)), r(1:61), fliplr(r(1:61)), r(1:61), fliplr(r(01:61))];
%polarplot(thetaa,v);
[x, y] = pol2cart(thetaa, v);
% ### plot y as x and -x as y ###
plot(y,-x);
hold on;
end
pbaspect([1 1 1]);
grid on;
xlabel('x-axis');
ylabel('y-axis');

More Answers (0)

Categories

Find more on MATLAB Parallel Server in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!