Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error using ==> stem at 40 X must be same length as Y.

929 views
Skip to first unread message

kailatzakis

unread,
Nov 27, 2010, 12:33:04 PM11/27/10
to
V = 5;
k = -10:10;
m=1;

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

Wayne King

unread,
Nov 27, 2010, 4:08:03 PM11/27/10
to
"kailatzakis " <pns...@yahoo.com> wrote in message <icrfcf$4cb$1...@fred.mathworks.com>...

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

kailatzakis

unread,
Nov 28, 2010, 3:10:05 AM11/28/10
to
"Wayne King" <wmki...@gmail.com> wrote in message <icrrvj$l00$1...@fred.mathworks.com>...


Thanks Wayne that was what i was looking for

0 new messages