I have the code for a decaying sinusoid and I want to figure out how to reverse it
2 ビュー (過去 30 日間)
古いコメントを表示
function xs = myDecayingSinusoid(A, b, omega, phi, fs, tStart, tEnd)
A = 6;
b = .9;
omega = 60 .* 2 .* pi;
phi = pi ./ 3;
fs = 15;
tStart = 0;
tEnd = 3;
tt = [tStart:1 / fs: tEnd];
xs = A * exp(-b * tt) .* cos(omega * tt + phi);
plot(tt, xs, 'b-')
end
0 件のコメント
回答 (1 件)
Star Strider
2022 年 8 月 31 日
I have no idea what ‘reverse’ means in this context. If you want to change ‘tt’ the easiest way is to re-code it as:
tt = linspace(tStart, tEnd, 1/Fs)/Fs;
then to revferse it simply reverse the values of ‘tStart’ and ‘tEnd’ in the function call. The linspace function does the rest. If you want to reverse the direction of the x-axis, after the plot call, add:
set(gca, 'XDir','reverse')
And of course, you can do both. Note that changing the linspace arguments alone will not change the plot appearance, because plot always plots with increasing values of the independent (x) variable vector.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!