Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Matlab program

Status
Not open for further replies.

snookdeal

Electrical
Joined
Sep 11, 2011
Messages
2
Location
US
Experts, Looking for a matlab program.

Generates signal h(i) with 17 samples defined as

h(i) = i , for 0<=i<=8
h(i) = 16-i , for 9<=i<=16
 
for i=1:8
h(i)=1;
end
for i=9:16
h(i)=16-i;
end


[peace]
Fe
 
You left h(0), that is what I am looking for.

Thanks
Snook
 
snookdeal - you will learn more figuring out your homework on your own.

=====================================
(2B)+(2B)' ?
 
It looks like the 3 micro seconds it took to give those basic 2 loops was 3 microseconds too much.

[peace]
Fe
 
If you need a 0 index, I suggest using Python instead of Matlab.
 
Python is good. But, it's no Matlab. There are other ways to get around the "0" index. This is IMO

[peace]
Fe
 
There's been more debate about zero-based indexing than there has been about the existence of God.

- Steve
 

Actually, Matlab *can* use zero-based indices. They are indicated with
an (unfortunately rather low precedence and rather obscurely
documented) prefix operator "1+", i.e.

a(1+(0:m))

Actually, it doesn't seem so obscure to me.
1+(0:2)
evaluates to
1 2 3
as expected. We are just converting the index we prefer to see (0:...) to the index matlab wants (1:...).

Maybe there is some subtlety that I'm missing.


=====================================
(2B)+(2B)' ?
 
Ummm, I was being facetious since he was obviously a student poster required to program something in Matlab.

But I do prefer Python due to 1) I work for a small company that won't shell out the cash for Matlab and 2) the existence of tools like pythonxy.
 
Don't worry Brad, I lol'd when I read your post. I was right there with you.
 
I meant no offence Brad. I agree with your points. [smile]

As for the "a(1+(0:m))" this is just adding 1 to the original index. It works, does it really matter if we end at m+1 instead of m? I would imagine in most cases no.

There's been more debate about zero-based indexing than there has been about the existence of God.

I'm with you on this. So let's leave it to God then [pipe]

[peace]
Fe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top