Effacer les filtres
Effacer les filtres

Alternating forward and reversed cos function

1 vue (au cours des 30 derniers jours)
Xymbu
Xymbu le 15 Mar 2022
Réponse apportée : Xymbu le 15 Mar 2022
I have a function that im not really sure how to get a matlab function for. I have several cycles of a cosine function, then those cycles are reversed and that pattern is repeated indefinitley. It's like a rastor scan over time. I am trying to find a way to come up with an equation for this so that I dont have to store all the data in a matrix ahead of time because the matrix becomes huge and takes up too much memory. Anyone have any ideas?
  1 commentaire
Torsten
Torsten le 15 Mar 2022
I have several cycles of a cosine function, then those cycles are reversed and that pattern is repeated indefinitley.
This means what mathematically ? For what are you trying to find an equation ?

Connectez-vous pour commenter.

Réponse acceptée

John D'Errico
John D'Errico le 15 Mar 2022
This may be easier than you think. But since you asked, and had no idea how to do it, it may be harder than you think. DRAT. Now I'm so confused.
The trick is to start by generating a version of a sawtooth function, but a specific kind thereof.
sawtooth = @(t,period) abs(mod(t+period,2*period) - period);
period = 2*pi;
fplot(@(t) sawtooth(t,period),[0,50])
So now your forward and reverse cosine function will be simple. For example, suppose you have a function that is a normal cosine function on the interval [0,5]. but then it reverses direction.
Easy peasy now!
compositecos = @(t) cos(sawtooth(t,5));
fplot(compositecos,[0,50])
The nice thing is, the sawtooth function I wrote above will work when composed with any function you want.
As I said, easier than you may think. As long as you think a bit outside of the box.

Plus de réponses (1)

Xymbu
Xymbu le 15 Mar 2022
This is what I was looking for. What I am actually applying this to is a little bit more complex than how I poorly explained it. It has a few more dimensions but I had never done this method but I was able to apply this and it works well so thanks!

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by