Question

suppose that we have following model,where phases are uniformly distributed in range of [-pi pi]

clear all;
A1=24;
A2=23;
A3=23;
A4=23;
A5=10;
 f1=12;
 f2=14;
 f3= 20;
 f4=7;
 t=0:0.01:2.94;
 phi=2*pi*(rand(1,4)-0.5);
 x=rand(length(t));
 y=A1.*sin(2*pi*f1*t+phi(1))+A2.*cos(2*pi*f1*t+phi(2))+A3.*sin(2*pi*f1*t+phi(3))+A4.*cos(2*pi*f1*t+phi(4))+A5.*x;

but it shows me error that

Error using  + 
Matrix dimensions must agree.

Error in stationary (line 14)
 y=A1.*sin(2*pi*f1*t+phi(1))+A2.*cos(2*pi*f1*t+phi(2))+A3.*sin(2*pi*f1*t+phi(3))+A4.*cos(2*pi*f1*t+phi(4))+A5.*x; 

also pleas ei had such question,when it is saying phases are uniformly generated,does it means that at once they should be generated and then used in signal or at each iteration,new phases should be generated?thanks in advance

UPDATE :

i have updated code like this

clear all;
A1=24;
A2=23;
A3=23;
A4=23;
A5=10;
 f1=12;
 f2=14;
 f3= 20;
 f4=7;
 phi=2*pi*(rand(1,4)-0.5);
 t=0:0.01:2.93;
x=rand([1,length(t)]);
 y=A1.*sin(2*pi*f1*t+phi(1))+A2.*cos(2*pi*f1*t+phi(2))+A3.*sin(2*pi*f1*t+phi(3))+A4.*cos(2*pi*f1*t+phi(4))+A5.*x;

is everything correct?main point is about phases

Was it helpful?

Solution

I do not understand clearly the question, but regarding the error message: you are trying to sum a 295x295 matrix with a 1x295 vector, which fails:

You probably mean:

x=rand([1,length(t)]);

instead of

x=rand(length(t));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top