How can I plot 10 shifted single impulses in one plot (in a row)?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Paul
2025-6-25
编辑:Paul
2025-6-25
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!