I have the code for a decaying sinusoid and I want to figure out how to reverse it
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 31 Aug. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!