Color gradient for graph in a for loop
이전 댓글 표시
Hi everyone!
I'm plotting 3 force vs displacement plots in the same picture. For one of the lines in the plot, i'd like the color to gradually chance, so to be able to identify the change of the curve throughout the iterations. I would also like the legend of the figure to show a color bar which indicated e.g that the color becomes darker/lighter as the iteration progresses.
So far I have something like this (this is a pseudocode ofc):
fe = 1:0.1:100;
n_freq = length(fe);
for kk= 1:n_freq
[r,z] = ode23s('Nonlin', tspan x0);
x = z(:,1);
F = z(:,2);
F2 = z(:,3);
Ftot = F + F2;
figure(1)
hold on
plot(x, Ftot) %this is the plot which I would like to change gradually per each iteration of the for loop
hold on
plot(x, F)
hold on
plot(x,F2)
end
Can someone help me out? Thanks!
채택된 답변
추가 답변 (1개)
Wha about this?
x = [0:.2:10 nan];
y = sin(x);
patch(x,y,y,'edgecolor','interp','linewidth',2)
colorbar
카테고리
도움말 센터 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

