필터 지우기
필터 지우기

Plot legend labels using loop

조회 수: 3 (최근 30일)
Panos Kerezoudis
Panos Kerezoudis 2023년 4월 5일
댓글: Panos Kerezoudis 2023년 4월 8일
I am plotting the power spectrum from 16 channels. PSD was calculated using the pwelch function and its output has 3 dimensions: (Channels) x (Frequency index) x (Trial). Is there a way to produce the legend (data 1, data 2,...) with the channel numbers using a for loop, in order to avoid writing down all 16 labels?
thank you!
Here is what i get by the way:
figure(1), hold on
plot(f, mean(pwrsignal(:,:,:), 3), 'LineWidth', 2)
xlim([0 200])
legend

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 4월 5일
data = rand(100,16);
plot(data)
legend("data " + (1:size(data,2)))

추가 답변 (0개)

카테고리

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