【发布时间】:2015-12-15 11:07:50
【问题描述】:
让我们以我为模拟算术布朗运动而编写的这段代码为例:
%% Simulate an arithmetic Brownian motion
% $$ dX(t) = mu*dt + sigma*dW(t) $$
% Define parameters and time grid
npaths = 500; % number of paths (trajectories)
T = 1; % time horizon
nsteps = 150; % number of time steps
dt = T/nsteps; % time step size
t = 0:dt:T; % observation times
mu = 0.2; sigma = 0.3; % model parameters
% Compute the increments
dX = mu*dt + sigma*sqrt(dt)*randn(nsteps,npaths);
% Accumulate the increments: compute the ABM
X = [zeros(1,npaths); cumsum(dX)]; % sets first row as zero
% Plot 20 sample trajectories
figure(1);
plot(t,X(:,1:20)); % just select 20 trajectory for clarity's sake
在这里我绘制了 20 条轨迹,但我想找到一种方法来更改我选择的任意数量的轨迹的颜色图。我想要更鲜艳的颜色。每次我绘制任何随机过程模拟时都会遇到这个问题,所以我正在寻找我每次都可以使用并且可能很简单的通用方法。有谁知道该怎么做?
【问题讨论】:
-
要生成任意数量的最大感知不同颜色(如果担心的话?)你可能想看看this Matlab central submission。要控制颜色显示的顺序,请查看
ColorOrder属性。 -
您可以在
plot命令中使用Color选项,并使用一些工具来生成颜色图,例如blogs.mathworks.com/pick/2008/08/15/…