Plotting graphs with different colours for each line
조회 수: 1 (최근 30일)
이전 댓글 표시
Good afternoon. I have lots of sets of data. The frequency range is 120:135 Hz and my other variable if f in the code below. I want to plot a graph of t,x(:,6), this will have five lines on it (one line for each value of f) when I plot it the lines are all blue, how do I change the colours?
my data is saved as follows: varying_u_freq_XXX_u_YYY.mat where XXX and YYY vary to specify different data sets.
Here is my code:
clf;
hold on;
for freq=(135);
for f=(0.02:0.02:0.1);
load( ['varying_u_freq_' ,num2str(freq) '_u_' ,num2str(f) '.mat'] );
fprintf('.');
%figure
plot(t,x(:,6));
title('frequency range vs mean voltage')
xlabel('frequency range (Hz)')
ylabel('mean Voltage (v)')
end
end
fprintf('\n');
thanks for your help
댓글 수: 0
답변 (1개)
jeff wu
2012년 4월 22일
try this
for other colors you have to use the rgb code
colors = {'red', 'green', 'blue', 'cyan', 'magenta', 'yellow'}
for freq=(135);
i = 1;
for f=(0.02:0.02:0.1);
load( ['varying_u_freq_' ,num2str(freq) '_u_' ,num2str(f) '.mat'] );
fprintf('.');
%figure
plot(t,x(:,6),colors{i});
title('frequency range vs mean voltage')
xlabel('frequency range (Hz)')
ylabel('mean Voltage (v)')
i = i+1;
end
end
fprintf('\n');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!