How can I plot 10 shifted single impulses in one plot (in a row)?
2 views (last 30 days)
Show older comments
I've got 2 impulses with different number of points: imp and S0. I need to plot all impulses together: imp, S0 and the result of adding - 10 impulses Si.
How can I do that?
Thank you!
ub = 10;
x_imp = linspace(-ub, ub, 1001);
x_S0 = linspace(-ub, ub, 2002);
imp = sech(x_imp);
S0 = sech(x_S0 + ub/2 * sign(x_S0) +ub/2);
figure(1);
plot(x_S0, S0, 'LineWidth', 2, 'Color', 'red');
hold on;
plot(x_imp,imp,'--', 'LineWidth', 3, 'Color', 'blue');
% getting S0 and 10 signals Si
i_steps = 10;
dt = 10/i_steps; % shift
Si = zeros(size(x_S0));
for i_steps = 0:10
shift = i_steps*dt;
Si = sech (x_S0 + ub/2 * sign(x_S0) + shift);
end
0 Comments
Accepted Answer
Paul
on 25 Jun 2025
Edited: Paul
on 25 Jun 2025
imp = @(x) sech(x);
S0 = @(x) imp(x).*(x<=0); % assumes S0(0) = sech(0)
ub = 10;
x_imp = linspace(-ub, ub, 1001);
x_S0 = linspace(-ub, ub, 2002);
figure(1);
plot(x_S0, S0(x_S0), 'LineWidth', 2, 'Color', 'red');
hold on;
plot(x_imp,imp(x_imp),'--', 'LineWidth', 3, 'Color', 'blue');
i_steps = 10;
dt = 10/i_steps; % shift
Si = zeros(numel(x_S0),i_steps+1);
for i_steps = 0:10
shift = i_steps*dt;
Si(:,i_steps+1) = S0(x_S0 + shift);
end
figure
plot(x_S0,Si)
More Answers (0)
See Also
Categories
Find more on Specifying Target for Graphics Output 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!