for m = 1:length(k)
if mod(k(m),2)~=0
Ck = (-V*2*j)./(pi*k(m));
end
end
subplot(2,1,1),stem(k,abs(Ck))
subplot(2,1,2),stem(k,angle(Ck))
i cant find the problem i keep getting the following error ..
??? Error using ==> stem at 40
X must be same length as Y.
Error in ==> Fourier at 14
subplot(2,1,1),stem(k,abs(Ck))
I tried to set Ck as a vector but still.. please help
Hi, In your loop you are always setting Ck as a scalar. So Ck ends up being 1x1. Since we don't know what you are trying to do, it's hard to offer specific advice, but
V = 5;
k = -10:10;
m=1;
Ck = zeros(size(k));
for m = 1:length(k)
if mod(k(m),2)~=0
Ck(m) = (-V*2*j)./(pi*k(m));
end
end
stem(k,abs(Ck));
will enable you to plot your result. Again, you'll have to decide whether this is producing the output you expect.
Wayne
Thanks Wayne that was what i was looking for