Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentarios
Nate
Nate el 4 de Oct. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Guillaume
Guillaume el 4 de Oct. de 2014
Editada: Guillaume el 4 de Oct. de 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 .*

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by