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

回答(1 个)

jeff wu
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');

类别

Help CenterFile Exchange 中查找有关 Data Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by