Need to plot multiple lines

조회 수: 1 (최근 30일)
Dustin
Dustin 2011년 3월 22일
Hi there I'm just trying to get matlab to make a simple plot with multiple lines using a for loop, and i have not had much luck anywhere else. my code is:
for a = 1:20 x = 0:0.001:2*pi; y = a*sin(x); plot(x,y) end
I want 5 lines all with different amplitude of a going from 1 to 20. However i only get one plot output with amplitude 20. What is the best way to make this happen?

채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 22일
hold on %put this code before your code

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by