animated sine wave continously
31 ビュー (過去 30 日間)
Hi alll, i'd like to make sine wave with three variation and walk continously, but i end up make it uncontinously,
here the script that i modified, any suggestion to solve it?
t = 0:0.01:10*pi;
y = cos(t+phase);
for j = 1:length(t)
axis([0 8*pi -2 2]) % moving 2 cycles would mean the end would be 4pi + 2*2pi = 8pi
% you can keep the axis endpoints according to your need
if j ~= length(t)
t = t + 0.1; % used 0.1 increment as elements in t have 0.1 difference
% Also, as y is already defined earlier, this change in t will not change y
Les Beckham 2023 年 3 月 30 日
編集済み: Les Beckham 2023 年 3 月 30 日
This should get you started. Adjust as desired.
Note that the animation won't show here, but I tested it my local copy of Matlab.
t = linspace(0, 4*pi, 1000);
y = sin(t);
hl = plot(t, y);
set(hl, 'YData', circshift(get(hl, 'YData'), 1))
% you may want -1 here ^
% depending on which direction you want to scroll