필터 지우기
필터 지우기

How to display legend

조회 수: 3 (최근 30일)
jy tan
jy tan 2012년 3월 17일
Let's say i use a for loop for different values of alpha, each alpha will generate different results. How will I use the legend to differentiate the colors
for alpha=0.1:0.1:1
plot(T,CF); legend('alpha=0.x');
end

답변 (1개)

Walter Roberson
Walter Roberson 2012년 3월 17일
alphas = 0.1:0.1:1;
for alpha = alphas
plot(T,CF); %presumed depends on alpha
end
legendstr = cellstr( num2str( alphas(:), 'alpha=%.1f' ) ) );
legend( legendstr );
Note: it is important for this purpose that the first parameter to num2str() be a column vector and not a row vector.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by