Matlab help

• Sep 20th 2008, 11:43 AM
george
Matlab help
Hey, im new to programing in matlab and am having a really hard time with it so far. Im stuck on this one problem:

Define vector xi=(i-m)/(m+3); i=1,...,(2m-1) using a single loop

could someone help me out here. im not even really sure how to start this.
I know how to do simple loops like
for i=1:1:5
x=x+8
end

but thats as far as my skills go right now.
Any help would be awesome
• Sep 20th 2008, 11:59 AM
CaptainBlack
Quote:

Originally Posted by george
Hey, im new to programing in matlab and am having a really hard time with it so far. Im stuck on this one problem:

Define vector xi=(i-m)/(m+3); i=1,...,(2m-1) using a single loop

could someone help me out here. im not even really sure how to start this.
I know how to do simple loops like
for i=1:1:5
x=x+8
end

but thats as far as my skills go right now.
Any help would be awesome

i posted this in the programing section too, so feel free to delete that one.

With one loop:

Code:

```m=10; xi=zeros(1,2*m-1); for idx=1:2*m-1;   xi(idx)=(idx-m)/(m-3); end```
With zero loops

Code:

```m=10; xi=([1:2*m-1]-m)/(m-3);```
RonL
• Sep 20th 2008, 12:01 PM
bkarpuz
Quote:

Originally Posted by george
Hey, im new to programing in matlab and am having a really hard time with it so far. Im stuck on this one problem:

Define vector xi=(i-m)/(m+3); i=1,...,(2m-1) using a single loop

could someone help me out here. im not even really sure how to start this.
I know how to do simple loops like
for i=1:1:5
x=x+8
end

but thats as far as my skills go right now.
Any help would be awesome

i posted this in the programing section too, so feel free to delete that one.

I have the following code, which may help you to learn the idea.

Code:

```s=100; k=3; for n=1:(k+1)     x(n)=1; end; for n=(k+1):(s-1)     mn=mod(n,12);     if mn==0         p=-1;     elseif mn<=3         p=0;     else         p=245/1000;     end;     x(n+1)=x(n)-p*x(n-k); end; n=1:s plot(n,x(n),'-rs','LineWidth',1,'MarkerEdgeColor','b','MarkerSize',2) %n=1:(s-1) %plot(x(n),x(n+1),'-rs','LineWidth',1,'MarkerEdgeColor','b','MarkerSize',2) grid on;```
It's better you ask stuff like this to http://www.mathhelpforum.com/math-he...uter-software/
(Wink)
• Sep 20th 2008, 01:53 PM
george
can someone explain to me what "idx" means?
thanks

never mind. "idx" is just a variable i think
but could some one help me understand what the code is doing?

haha.. never mind. i understand it. Im learning, just very slowly.
• Sep 21st 2008, 11:26 PM
bkarpuz
Quote:

Originally Posted by george
can someone explain to me what "idx" means?
thanks

never mind. "idx" is just a variable i think
but could some one help me understand what the code is doing?

haha.. never mind. i understand it. Im learning, just very slowly.

idx is the name of the counter that runs from 1 to 2*m-1 1 by 1.

a very helpful website for the questions is MATLAB