How to make a colour gradient with 60 lines on a graph
Mostra commenti meno recenti
I have a program that puts 60 lines onto a singular graph. The 60 lines are the same equation being plotted with one variable changing for each iteration using a simple for loop. I was wondering if there was a way to make the lines change colours in a gradient so that the graph is easier to read by implementing a key. For example, as the value increases the colour would change gradually from yellow to orange to, finally, red. Here is the program for reference:
format long
%DECLARE VARIABLES
M = 10000002;
w = zeros(M,1);
e = zeros(M,1);
dw = zeros(M-1,1);
de = zeros(M-1,1);
T = [0:10000000];
e(1) = 0.0549;
w(1) = 0.3844e9;
for g = 12.0:0.1:18.0
for m = 0:10000000
de(m+1) = -(4e41 + (2.e40)/g) * ((w(m+1))^(-13/2)) * e(m+1);
dw(m+1) = -((8.1e41)*(e(m+1)^2) + ((1.2e40)/g)) * (w(m+1))^(-11/2);
e(m+2) = e(m+1) + (de(m+1) * 3.154e7);
w(m+2) = w(m+1) + (dw(m+1) * 3.154e7);
end
e = e(1:end-1);
w = w(1:end-1);
plot (T, w)
hold on
end
hold off
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su 2-D and 3-D Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

