Plotting graphs with different colours for each line
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
jeff wu
le 22 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!