make one part of a function repeat it self in diffrent sections of time line.

2 ビュー (過去 30 日間)
Yotam Rotelman
Yotam Rotelman 2020 年 4 月 2 日
回答済み: Akira Agata 2020 年 4 月 2 日
N = 10000;
t = linspace(-3*pi, 3*pi, N + 1)'; t(end) = [];
x = -t;
figure; hold on; grid on;
plot(t, x, 'b', 'LineWidth', 1)
legend('x(t)');
xlabel('t');
ylabel('x(t)');
this is my code and my input funciton is x=-t
i want the plot graph to repeat it self this way in intervals of 2*pi:
now,obviously the plot is just the function -t in the interval {-3pi,3pi} without repitations.
I cant find the right syntax to do it.
if someone has an idea , i could use the help. thanks

採用された回答

Yotam Rotelman
Yotam Rotelman 2020 年 4 月 2 日
found the solution. these will create 3 iepitations.
%%1
N = 10000;
t = linspace(-pi, pi, N + 1)'; t(end) = [];
x = -t;
t1 = linspace(-3*pi, 3*pi, 3*N)';
X=[x;x;x];
figure; hold on; grid on;
plot(t1, X, 'b', 'LineWidth', 1)
legend('x(t)', 'y(t)');
xlabel('t');
ylabel('x(t)');

その他の回答 (1 件)

Akira Agata
Akira Agata 2020 年 4 月 2 日
If you have a Signal Processing Toolbox, you can simply use sawtooth function, like:
% Generate signal
t = linspace(-4*pi,4*pi,1000);
y = -1*pi*sawtooth(t-pi);
% Plot the waveform
figure
plot(t,y)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by