Effacer les filtres
Effacer les filtres

Creating a matrix of sinusoids with time increasing over rows, and frequency + phase increasing stepwise over columns

1 vue (au cours des 30 derniers jours)
I need to create a matrix/array of sinusoids with time vector increasing along rows and frequency vector increasing along columns together with a phase vector. The frequency vector and phase component of the sinusoids each increase stepwise on a logarithmic scale.
Something like this:
t = t1:int:n;
f = logspace(-1,4,100);
p = logspace(-1,pi,100);
y(t, f, p) = sin(2*pi*f*t + p)
The desired result is as follows (column and row headings are added for clarity of the question here):
Y{} =
f1/p1 f2/p2 ... f100/p100
-- --
t1 |sin(2*pi*f1*t1 + p1) sin(2*pi*f2*t1 + p2) ... sin(2*pi*f100*t1 + p100)|
t2 |sin(2*pi*f1*t2 + p1) sin(2*pi*f2*t2 + p2) ... sin(2*pi*f100*t2 + p100)|
...| ... ... ... ... |
tn |sin(2*pi*f1*tn + p1) sin(2*pi*f2*tn + p2) ... sin(2*pi*f100*tn + p100)|
-- --
Help is hugely appreciated, thanks
  2 commentaires
Star Strider
Star Strider le 4 Oct 2014
What about the answers provided to you in Creating a matrix of sinusoids with frequency increasing over columns and time increasing over rows didn’t work for you after you accepted it and got more than one good answer?
Nate
Nate le 4 Oct 2014
In that previous question there was no phase vector. The answers to my prior question do not work in this setting since they involved simple matrix multiplication. Here I need matrix multiplication + an addition of the phase component.

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
Guillaume le 4 Oct 2014
Modifié(e) : Guillaume le 4 Oct 2014
You would use ndgrid or meshgrid:
t = t1:int:n;
f = logspace(-1,4,100);
p = logspace(-1,pi,100);
[tt, ff] = ndgrid(t, f);
[~, pp] = ndgrid(t, p); %already got tt with first ndgrid
y = sin(2*pi*ff.*tt + pp); % be mindful of the by element multiply .*

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by