필터 지우기
필터 지우기

How do I plot two different variables on the same graph but in two different colors?

조회 수: 5 (최근 30일)
I am trying to plot a "butterfly curve" with the two formulas:
I got the plot to run, however, I would like x to be the color blue and y to be the color red. I cannot get the two seperate colors to show up for each variable. Here is my code:
clc
t=0:(0.0625):100;
ev=exp(1); %just the constant e
for i=1:2
hold on
x=sin(t).*(ev.^(cos(t))-(2.*cos(4*t))-(sin(t/12).^5))
y=cos(t).*(ev.^(cos(t))-(2.*cos(4*t))-(sin(t/12).^5))
plot(x,y)
end

답변 (1개)

Chunru
Chunru 2022년 8월 25일
편집: Chunru 2022년 8월 25일
clc
t=0:(0.0625):100;
x=sin(t).*(exp(cos(t))-(2.*cos(4*t))-(sin(t/12).^5));
y=cos(t).*(exp(cos(t))-(2.*cos(4*t))-(sin(t/12).^5));
%plot(t, x, t, y)
plot(x, y)
  댓글 수: 2
Michaela Crego
Michaela Crego 2022년 8월 25일
편집: Michaela Crego 2022년 8월 25일
Thank you for your reply. However, I believe it's supposed to maintain the shape of the "butterfly curve". I want to separate x and y completely but keep the same form - and create a color legend based on it.
See below:
My code to get this:
plot(x,y)
Chunru
Chunru 2022년 8월 25일
How do you separate x and y completely? In what sense?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by