mcarterbrown.com
Tippmann - US Army Paintball
 

General Chat MCB's Coffee House: Pull up a seat, and grab your favorite caffeinated beverage. Non-paintball related chat within.

Reply
 
LinkBack Thread Tools
Old 02-21-2008, 08:39 PM   #1 (permalink)
Active Member
 
Siress's Avatar
 
Join Date: Sep 2006
Location: NW GA
Posts: 346
Need more brain power - MATLAB Questions

I've been trying to do these for several days now and I cannot figure it out.

It's Chapter 11 in David Smith's Concepts in Computer Science, if any of you have it.

Here's what we've covered so far:
Scripts, vectors, conditional statements, iteration, fucntions, generic arrays, and structers.

This is the chapter on arrays. I've read it twice and understand the material, but I fail to make the connection to how we can use it to accomplish these problems. I appreciate any help! I'd really like to have fun with this program instead of frustrating myself with it.

Problem 2:
Write a function named fiddle that consumes a 2D array A and doubles the size of the array by replicating each item horizontally, vertically and diagonally. You should not need iteration to solve this problem.

EX:
>> A = [1 4 7; 8 5 3];
>> fiddle(A)
ans =
1 1 4 4 7 7
1 1 4 4 7 7
8 8 5 5 3 3
8 8 5 5 3 3

Problem 4:
Write a function named rowProduct that will take in one parameter: a 2D array named A. This function will calculate the product of the even values in each row and store that product in a vector. If a row has one even value, the product will be simply that value. If there are no even values, the product is one.

EX:
>> rowProduct([1 2 4; 3 6 9; 0 6 8; 5 7 9])
ans =
8 6 0 1

Problem 6:
Write a function called multiples that takes in an array (of any dimensionality) called numbers and a number called divisor, and then returns a vector called multiplesVec that contains only those elements of numbers that are multiples of divisor. If there are no elements in the array numbers or the resulting vector, your function should return an empty vector. You should not need iteration to solve this problem.
__________________

-Integrity is doing what is right, even when no one is looking.-

SCP Feedback PHOG Feedback PBN Feedback My eBay account
Siress is offline   Reply With Quote
Old 02-21-2008, 09:22 PM   #2 (permalink)
Every Dog has its Day
 
netsurferdude2's Avatar
 
Join Date: Mar 2006
Location: Northern MD
Posts: 1,697
Send a message via AIM to netsurferdude2 Send a message via Skype™ to netsurferdude2
We did alot of MATLAB last semester. I forgot how much I hated it!

I will look through some of my old notes and see if I can figure it out.
__________________
-Greg F. aka "netsurferdude2"
Check Out My Site (I will update soon)
My Gallery
Quote:
Originally Posted by Drum View Post
When I worked in the county prison, all my pals among the correctional officer staff were always talking about how they needed a large(r) caliber handgun in case they were confronted by someone on "PCP" or "Angel dust".

Now... all they talk about is zombies.
netsurferdude2 is online now   Reply With Quote
Old 02-21-2008, 09:24 PM   #3 (permalink)
MCB Member
 
Join Date: Jul 2006
Posts: 1,265
yuck.

best thing about matlab - similink simulations!
__________________
the ultimate truth in paintball is that the interaction between the gun and the player is far and away the largest factor in accuracy, consistency, and reliability.

>>PAINTBALL SCIENCE!<<
"Originally posted by Garbageman705: Arguing with Cockerpunk is like fighting a T-Rex. Your going to get your *** kicked."
cockerpunk is offline   Reply With Quote
Old 02-22-2008, 02:08 AM   #4 (permalink)
Active Member
 
Siress's Avatar
 
Join Date: Sep 2006
Location: NW GA
Posts: 346
Ok, iteration is allowed. I solved 4 and 6 quickly. Problem 2 is a mystery to me....anyone?!
__________________

-Integrity is doing what is right, even when no one is looking.-

SCP Feedback PHOG Feedback PBN Feedback My eBay account
Siress is offline   Reply With Quote
Old 02-22-2008, 02:21 AM   #5 (permalink)
MCB Member
 
Sir Brass's Avatar
 
Join Date: May 2006
Location: Phoenix, AZ
Posts: 913
Send a message via AIM to Sir Brass
THis is pointless. They're treating MATLAB like an overpowered graphing calcuator. That's NOT what it was meant for. MATLAB really shines when you're doing control system modeling, signal analysis, and other matrix-based problems/models (like systems of equations).

For example. When I took DSP, one of our assignments was to take a "dialer" program (you'd change the #'s you wanted dialed in the script file) that would, when run, play the touch-tone phone tones of the #'s you wanted dialed, and then save the output to a file. We were to take THAT output file (we were given the dialer program already written. and the output file was the audio waveform) and using matlab, decode what numbers where dialed. Basically it was practice using comb filters and resonators to figure out what row and column frequencies occurred WHEN, and based on that, interpret which button was pressed, and thus determine which number was dialed when.

THAT is good use of matlab. It's a very powerful tool when used like it was meant to be used. It's NOT meant to be used as an overpowered graphing calculator. It's a bit complex for that. But for high level problems, the complexity is NOTHING and it's simple to write a script file that does the math, solution analysis and graphing all in one run.
__________________
"Greater love hath no man than this, that a may lay down his life for his friends." John 15:13
Quote:
Originally Posted by Harbinger[TG] View Post
Is this your new way to kill time since you can't buy any more guns.
^Said to Mar about SIG repository.
Quote:
Originally Posted by pillage View Post
They put a hit out on Yogi, but Boo Boo got whacked.

Proud owner of:
Palmer's aluminum + brass...... two of 'em
Sir Brass is offline   Reply With Quote
Old 02-22-2008, 02:31 AM   #6 (permalink)
Active Member
 
Siress's Avatar
 
Join Date: Sep 2006
Location: NW GA
Posts: 346
Great. Could you solve the pointless problem now? :P

Also, how did you use MATLAB to analyze the sound?
__________________

-Integrity is doing what is right, even when no one is looking.-

SCP Feedback PHOG Feedback PBN Feedback My eBay account
Siress is offline   Reply With Quote
Old 02-22-2008, 03:13 AM   #7 (permalink)
MCB Member
 
Sir Brass's Avatar
 
Join Date: May 2006
Location: Phoenix, AZ
Posts: 913
Send a message via AIM to Sir Brass
We used the tools in the signal analysis toolbox. I forget the exact functions, except for conv() (for convolving) and freqs() (for doing frequency response in the s-domain....which is what you do for analog signals. you use freqz() for doing the z-transform in order to do digital signals).

But we used comb filters with center frequecies to isolate the frequencies involved, and then used resonators which would resonate at those frequencies. See, a touch-tone phone mixes two tones when you push a button, one tone is for the column the button is in, and the other for the row. These frequencies are known. So, you set up 6 resonators (one for each frequency) and run the comb-filtered signal through those resonators. Then you can analyze the output of each resonator to find out when each tone occurred (a resonator will respond when a signal with it's resonating frequency goes through it), and correlate by time which frequencies were triggered WHEN and thus use the row and column frequencies like x and y coordinates. Automating that in matlab was a cinch. It was setting up the filter and resonators that was tricky. THEN thinking up of the code structure to logically process the resonator outputs and determine the # dialed. I forgot how I went through each resonator and picked up when a resonator was activated. but, I did, and then went through a case statement imbedded in a while loop and matched row and column frequency combinations to #'s. Took about 3 hours total.

Note: this was done in my first semester of my senior year of college: Fall of '05. That's 2.5 years ago. I don't remember the specifics. What I was saying about it being pointless is to not worry yourself over not getting some of this, and to know that there IS good and excellent uses for MATLAB that make it a very powerful tool.
__________________
"Greater love hath no man than this, that a may lay down his life for his friends." John 15:13
Quote:
Originally Posted by Harbinger[TG] View Post
Is this your new way to kill time since you can't buy any more guns.
^Said to Mar about SIG repository.
Quote:
Originally Posted by pillage View Post
They put a hit out on Yogi, but Boo Boo got whacked.

Proud owner of:
Palmer's aluminum + brass...... two of 'em
Sir Brass is offline   Reply With Quote
Old 02-22-2008, 03:17 AM   #8 (permalink)
Active Member
 
Siress's Avatar
 
Join Date: Sep 2006
Location: NW GA
Posts: 346
Ah. Well, in order to preserve my GPA I'd like to understand every bit of it. The fact that I'll be studying under the author of this book in the next few years means I really need to crack down and find a method to his madness. (and probably quit calling him a sadist... but this book....oh my god)

This book is like Yoga. You start out and it's all nice and relaxing. 'Breath deep.' 'Exhale.' 'Stretch your arms over your head.' 'Slowly lean backwards and stick your head up your ***'

EDIT: Got it! Without iteration... Just approached it from a different angle than suggested. Doubled the vectors columns, shuffled the columns, then did the same to the rows.
__________________

-Integrity is doing what is right, even when no one is looking.-

SCP Feedback PHOG Feedback PBN Feedback My eBay account

Last edited by Siress; 02-22-2008 at 07:36 AM.
Siress is offline   Reply With Quote
Reply

  mcarterbrown.com » General » General Chat

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Censor is On
Forum Jump



All times are GMT -4. The time now is 09:15 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0