문제

N=1000
n=1:N;
rng(1);
s1 = 0.2;
s2 = 0.8;
w1(n) = randn(N,1)*s1
w2 = randn(N,1)*s2
subplot(1,3,1)
y=(sin(n/50)+cos(n/200)-sin(n/100))
plot(n,y(n))
subplot(1,3,2)
y1(n) = y(n) + w1;
plot(n,y1(n))
subplot(1,3,3)
y2(n) = y(n)+w2 
plot(n,y2(n))

This code throws an error saying that the matrix dimensions should agree. Somebody please explain it.

도움이 되었습니까?

해결책

w2 is 1000x1 while y(n) is 1x1000. You have to transpose w2:

y2(n) = y(n)+w2.' 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top