Can we rotate the plot(x, y)

조회 수: 5 (최근 30일)
CHANDRABHAN Singh
CHANDRABHAN Singh 2021년 9월 23일
답변: Cris LaPierre 2021년 9월 23일
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.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 9월 23일
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');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by