How to change color each loop?

조회 수: 45 (최근 30일)
Ayob
Ayob 2013년 6월 15일
I have a program which should be repeated 5 times by a loop. I used plot() order in my program and I'm eager to change graph color each time. How can I do it?
For example:
plot(ZZ,dTdz3,'.',h,t,'y')
I want to change 'y' to 'm' in the next loop.
note: ZZ and dTdz3 are matrices and h and t help me make a line, none of them looks important in my question to you.

채택된 답변

Image Analyst
Image Analyst 2013년 6월 15일
편집: Image Analyst 2013년 6월 15일
Use the 'Color' option of plot:
ZZ = 1:5;
for k = 1:10
dTdz3 = rand(1,5);
plot(ZZ,dTdz3, 'Color', rand(1,3), 'LineWidth', 3)
hold on;
end

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 15일
편집: Azzi Abdelmalek 2013년 6월 15일
couleur='ym'
for k=1:2
plot(ZZ,dTdz3,'.',h,t,couleur(k))
end
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 15일
You can also use hold all to obtain different color

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by