Im having trouble with unit step functions
Show older comments
I need to create a program that evaluates 4 signals correlation coefficients. The signals are
a. X1(t)=u(t+0.5)-u(t)-u(t)+u(t-0.5)
b. X2(t)=(t+0.5)*[u(t+0.5)-u(t)] + (0.5-t)*[u(t)-u(t-0.5)]
c. X3(t)=sin(2*pi*t)*[ u(t+0.5)-u(t-0.5)]
d. X4(t)=cos(4*pi*t)*[ u(t+0.5)-u(t-0.5)]
I keep getting this error "Output argument "u" (and maybe others) not assigned during call to "u".
Error in sign_cor (line 5)
x1=u(t+0.5)-u(t)-u(t)+u(t-0.5);
This is my code so far:
Dt=0.01;
T=6.0;
t=[-1:Dt:T];
x1=u(t+0.5)-u(t)-u(t)+u(t-0.5);
x2=(t+0.5)*[u(t+0.5)-u(t)]+(0.5-t)*[u(t)-u(t-0.5)];
x3=sin(2*pi*t)*[u(t+0.5)-u(t-0.5)];
x4=cos(4*pi*t)*[u(t+0.5)-u(t-0.5)];
E0=sum(x1.*conj(x1))*Dt;
E1=sum(x2.*conj(x2))*Dt;
E2=sum(x3.*conj(x3))*Dt;
E3=sum(x4.*conj(x4))*Dt;
ab=(x1.*conj(x2))*Dt/(sqrt(E0*E1))
ac=(x1.*conj(x3))*Dt/(sqrt(E0*E2))
ad=(x1.*conj(x4))*Dt/(sqrt(E0*E3))
bc=(x2.*conj(x3))*Dt/(sqrt(E1*E2))
bd=(x2.*conj(x4))*Dt/(sqrt(E1*E3))
cd=(x3.*conj(x4))*Dt/(sqrt(E2*E3))
Answers (1)
Adam Danz
on 5 Feb 2019
0 votes
As the error indicates 'u' is not defined. Assuming it's a variable, it has no value and is not defined. If it's a function, Matlab doesn't know it exists.
Categories
Find more on Correlation and Convolution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!