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

1 次查看(过去 30 天)
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 个评论
Nate
Nate 2014-10-4
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.

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2014-10-4
编辑:Guillaume 2014-10-4
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 .*

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by