필터 지우기
필터 지우기

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