Plotting graphs with different colours for each line
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
jeff wu
am 22 Apr. 2012
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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Exploration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!