How run the code including wiener process function
Show older comments
I understand the code, but I'm not sure what the mistake is or why the Wiener function is causing a problem for me. Did I define something incorrectly? When I remove the Wiener term, the code works, but it must be included.
clc;
clear;
% Parameters
n = 1;
A = 1; % Amplitude
B = 1; % Width parameter of soliton
v = 1; % Velocity of soliton
alpha = 1; % Nonlinearity parameter
beta = 0.1; % Dispersion parameter
gamma = 0.05; % Noise intensity for multiplicative noise
% Grid for xi and time
xi = linspace(-20, 20, 2000); % Spatial range in transformed coordinates
t = linspace(0, 20, 1000); % Time range
dt = t(2) - t(1); % Time step
% Define initial soliton profile (deterministic solution)
u_deterministic = abs(((tanh(0.192e3 ./ 0.35e2 .* t' + xi) - 0.1e1) .^ (0.1e1 ./ 0.4e1)) .* exp(i * (-0.3e1 .* xi - 0.8e1 * t' + (3 .* w(t) ))));
% Ensure u_deterministic has the correct dimensions (time x space)
if size(u_deterministic, 1) ~= length(t) || size(u_deterministic, 2) ~= length(xi)
error('Mismatch in dimensions of u_deterministic. Check calculations.');
end
% Initialize storage for the stochastic solution
u_stochastic = zeros(length(t), length(xi));
% Generate Wiener process (increments) for time
W = cumsum(sqrt(dt) * randn(size(t))); % Wiener process for each time step
W = gamma * W; % Scale Wiener process by gamma
% Time evolution
for n = 1:length(t)
% Apply the Wiener noise factor at time step n
noise_factor = 1 + W(n);
% Update solution with multiplicative noise
u_stochastic(n, :) = u_deterministic(n, :) * noise_factor;
end
% Plot the 3D surface of the stochastic Kudryashov soliton
figure;
surf(xi, t, u_stochastic, 'EdgeColor', 'none');
xlabel('Transformed Space (\xi)');
ylabel('Time (t)');
zlabel('Amplitude (u)');
title('Stochastic Kudryashov Soliton Solution with Multiplicative Noise (Wiener Process)');
colormap jet;
colorbar;
Answers (1)
Cris LaPierre
on 14 Dec 2024
You use a function - w(t) - that you do not define in your code. At least that is the error I get in this line:
u_deterministic = abs(((tanh(0.192e3 ./ 0.35e2 .* t' + xi) - 0.1e1) .^ (0.1e1 ./ 0.4e1)) .* exp(i * (-0.3e1 .* xi - 0.8e1 * t' + (3 .* w(t) ))));
Assuming that is the wiener term you are referring to, what is it? It needs to be defined, too.
6 Comments
salim
on 14 Dec 2024
You have already written code for the Wiener process. Can't you just move it up to before you define u_deterministic and then use W' instead of w(t) in your expression?
% Parameters
n = 1;
A = 1; % Amplitude
B = 1; % Width parameter of soliton
v = 1; % Velocity of soliton
alpha = 1; % Nonlinearity parameter
beta = 0.1; % Dispersion parameter
gamma = 0.05; % Noise intensity for multiplicative noise
% Grid for xi and time
xi = linspace(-20, 20, 2000); % Spatial range in transformed coordinates
t = linspace(0, 20, 1000); % Time range
dt = t(2) - t(1); % Time step
% Generate Wiener process (increments) for time
W = cumsum(sqrt(dt) * randn(size(t))); % Wiener process for each time step
W = gamma * W; % Scale Wiener process by gamma
% Define initial soliton profile (deterministic solution)
u_deterministic = abs(((tanh(0.192e3 ./ 0.35e2 .* t' + xi) - 0.1e1) .^ (0.1e1 ./ 0.4e1)) .* exp(i * (-0.3e1 .* xi - 0.8e1 * t' + (3 .* W' ))));
% Ensure u_deterministic has the correct dimensions (time x space)
if size(u_deterministic, 1) ~= length(t) || size(u_deterministic, 2) ~= length(xi)
error('Mismatch in dimensions of u_deterministic. Check calculations.');
end
% Initialize storage for the stochastic solution
u_stochastic = zeros(length(t), length(xi));
% Time evolution
for n = 1:length(t)
% Apply the Wiener noise factor at time step n
noise_factor = 1 + W(n);
% Update solution with multiplicative noise
u_stochastic(n, :) = u_deterministic(n, :) * noise_factor;
end
% Plot the 3D surface of the stochastic Kudryashov soliton
figure;
surf(xi, t, u_stochastic, 'EdgeColor', 'none');
xlabel('Transformed Space (\xi)');
ylabel('Time (t)');
zlabel('Amplitude (u)');
title('Stochastic Kudryashov Soliton Solution with Multiplicative Noise (Wiener Process)');
colormap jet;
colorbar;
salim
on 15 Dec 2024
salim
on 15 Dec 2024
Cris LaPierre
on 16 Dec 2024
Perhaps this post is helpful: https://www.mathworks.com/matlabcentral/answers/457580-limits-are-too-large
Categories
Find more on Signal Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!