vertcat CAT arguments dimensions are not consistent.

1 次查看(过去 30 天)
I am implementing a code and exactly at the last loop after running for two iterations I have this error. I know this error is due to inconsistency in my arrays but i dont know where is the actual problem in the loop this is my code...
for tau = 1 : y
for k = 0:nw-1
S(1:nw,tau)= (((output(tau : tau + nw -1) - x(tau)).*exp(2*pi*k/nw))...
+ (x(nw-1+ tau).*exp(-2*pi*k*(nw-1)/nw)));
S = S(1:end/2);
end
Total = [Total; S.'];
end
  1 个评论
raj
raj 2012-1-31
I have an error in this line Total = [Total; S.']; but as for my requirment that is right way any way to avoid this error

请先登录,再进行评论。

回答(2 个)

Jan
Jan 2012-1-31
Is Total defined before the loops? If so, with which size?
It is strange, that you define S as a matrix at first and crop it to a vector in the next line. Are you sure?

raj
raj 2012-1-31
hallo Jan Simon this is my code may be it will help u in understanding better
Fs = 5e3;
t = 0:1/Fs:(10*1/Fs)-1/Fs;
x = cos(2*pi*1000*t)+cos(2*pi*1007*t);
w = rectwin(6)';
nw= length(w);
output = zeros(size(x));
for k = 0:length(x)-1
s= 0;
for n = 0:length(x)-1
s = s + x(n+1).*exp(-2*pi*1j*k*n/nw);
end
output(k+1) = s;
end
Total = [];
y = length(x) - nw;
for tau = 1 : y
for k = 0:nw-1
S(1:nw,tau)= (exp(2*pi*k/nw).*(((output(tau : tau + nw -1) - x(tau)))...
+ (x(nw-1+ tau).*exp(-(nw-1)/nw))));
S = S(1:end/2);
end
Total = [Total; S.'];
end
  1 个评论
raj
raj 2012-1-31
for tau = 1 the array works as i wanted but from tau = 2 the matrix dimensions change thats the problem any ideas how can i change the matrix dimensions

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by