# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

8 Pages

### hw02

Course: CS CS 1371, Fall 2008
School: Georgia Tech
Rating:

Word Count: 1129

#### Document Preview

This %========================================================================== % % homework is due on Thursday, August 28, 2008 at 11:45:00 PM with a % 6 hour grace period until Friday, January 19 at 6:00:00 AM. No late % submissions will be accepted. When you are finished, submit your % assignment to T-Square: (https://t-square.gatech.edu). % % Files provided with this homework: % - hw02.m % - prob1.m %...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Georgia >> Georgia Tech >> CS CS 1371

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Georgia Tech - CS - CS 1371
%=% PROBLEM 1. Creating Vectors%-% % For the following exercises, do not use the direct entry method to% construct the vectors.%clearclc% (a) Construct a vector containing all of the even numbers between 6 and% 33, inclusive of the end
Georgia Tech - CS - CS 1371
clearclc%=% PROBLEM 2. Indexing Vectors%-%% You are given a vector &quot;vec&quot;, defined as:vec = [45 8 2 6 98 55 45 -48 75];mask = [true false false false false true true false true]; vec = vec(mask)% In a brief moment of insanity you decide tha
Georgia Tech - CS - CS 1371
clearclc%=% PROBLEM 3. Functions to use with Vectors%-%% You are given a vector &quot;vec&quot;, defined as:vec = [45 8 2 6 98 55 45 -48 75];% (a) Create a variable called &quot;vLength&quot; that holds the length of the% vector &quot;vec&quot; modified in Problem
Georgia Tech - CS - CS 1371
clearclc%=% PROBLEM 4. Linspace Applicatioin%-% % Write a Matlab script to plot sin(x) vs. cos(x). In creating your plot% you should vary x from -pi to pi. A similar vector (&quot;theta&quot;) to x was% created in Problem 1(d) above. You should fin
Georgia Tech - CS - CS 1371
clearclcload twovec.matredvec = [];x = 1;y = 1;test = false;while test = false &amp; x &lt;= length(onevec) if sum(redvec) &gt; 10 test = true; end if test = false redvec(y) = onevec(x); end if sum(redvec) &gt; 10
Georgia Tech - CS - CS 1371
clearclcload bigvec.matx = 1;test = false;while test = false if bigvec(x) &gt; 401 if rem(bigvec(x),2) = 0 if rem(x,2) = 1 test = true; num = bigvec(x) end end end
Georgia Tech - CS - CS 1371
clearclcload houses.mattheMax = 0;x = 1;y = 1;while x &lt;= length(prices) if crime_rate(x) &lt; .5 &amp; sizes(x) &gt; 1000 &amp; prices(x) &lt; 250000 quality = (sizes(x)/(prices(x)*crime_rate(x); if quality &gt; theMax theMax = qu
Georgia Tech - CS - CS 1371
clearclcA = ones(1,5)B = 1:length(A)C = rand(1,1) * 10 if C &lt; 4 D = 0 elseif C &gt; 7 D = 1 else D = 2 endE = 0if D = 0 for x = A(B); E = E + x; endelseif D = 1 while E &lt; 10 E
Georgia Tech - CS - CS 1371
function [A B C D E] = ABCs_cell_arrays(C, ca1, ca2)% PROBLEM 3. The ABCs of Cell Arrays%% This is a multi-part problem. Do each of the parts below.%% DO NOT CHANGE THE FUNCTION HEADER (the first line of code)% a) Creating. Create a cell ar
Georgia Tech - CS - CS 1371
function [A B C D] = ABCs_conditionals(x, y, z)% PROBLEM 4. The ABCs of Conditionals%% This is a multi-part problem. Do each of the parts below.%% DO NOT CHANGE THE FUNCTION HEADER (the first line of code)% a) if statements. x is a number.
Georgia Tech - CS - CS 1371
function [A A_method B B_method C] = ABCs_iteration(x)% PROBLEM 5. The ABCs of Iteration%% This is a multi-part problem. Do each of the parts below.%% DO NOT CHANGE THE FUNCTION HEADER (the first line of code)% 1) for loops. Below are two fo
Georgia Tech - CS - CS 1371
function [A B C D E F G H I J] = ABCs_strings(ch1, str1, str2, str3, vec1, alph1, x, num1)% PROBLEM 2. The ABCs of Strings%% This is a multi-part problem. Do each of the parts below.%% DO NOT CHANGE THE FUNCTION HEADER (the first line of code)
Georgia Tech - CS - CS 1371
%PROBLEM 7%% Write a function named cellParse that takes in a cell array with each% element being either a string (character array), or a vector% (containing numbers), or a boolean value (logical array of length 1).% Your function should
Georgia Tech - CS - CS 1371
%PROBLEM 6%function output = cellUnwrap(A)while iscell(A{1}) = true A = A{1};endoutput = Aend
Georgia Tech - CS - CS 1371
function result = myStrCmpI(x, y) if (length(x) ~= length(y) result = false; return; enddiff = 'a' - 'A';i=1; while (i &lt;= length(x) &amp; (x(i) = y(i) | . (isletter(x(i) &amp; isletter(y(i) &amp; abs(x(i) - y(i) = diff)
Georgia Tech - CS - CS 1371
%PROBLEM 4%%% Write a function named myStrFindI that takes in two strings. Your% function should return a vector containing the starting index of all% the occurences of the first string within the second string. Your% function should
Georgia Tech - CS - CS 1371
function mySum = mySum(A)% computes the sum of the elements in the given vectormySum = 0;index = 1;while index &lt;= length(A) x = A(index); mySum = mySum + x; index = index + 1;endend
Georgia Tech - CS - CS 1371
%PROBLEM 2%function output = removeSpaces(A)% takes in a string and outputs the same string but with all the space characters removedindex = 1;while index &lt;= length(A); if uint8(A(index) = 32; A(index) = []; end index = index
Georgia Tech - CS - CS 1371
%PROBLEM 5%% Write a function named slowSort that takes in a vector, sorts it in % ascending order (smallest to largest), and then outputs it.%% Note: you may *not* use the built-in sort function in MATLAB.% function output = slowSort(A)
Georgia Tech - CS - CS 1371
function [A B C D] = ABCs_structure_arrays(str1, str2, str3, sa1)% PROBLEM 2. The ABCs of Structure Arrays%% This is a multi-part problem. Do each of the parts below.%% DO NOT CHANGE THE FUNCTION HEADER (the first line of code)%% a) Creatin
Georgia Tech - CS - CS 1371
function [A B C D E F G H I J] = ABCs_structures(a_name, a_price, b_name, b_price, st1, st2, f1, var1)% PROBLEM 1. The ABCs of Structures%% This is a multi-part problem. Do each of the parts below.%% DO NOT CHANGE THE FUNCTION HEADER (the firs
Georgia Tech - CS - CS 1371
%=% Problem 3. Sorting Structures%-%% In homework 4, you implemented an algorithm to sort a vector.% You will now implement the same algorithm to sort a structure array based% on one of its fields. To do this, please complete parts A and B bel
Georgia Tech - CS - CS 1371
% Problem Statment:%% Write a function named structFromCell that takes in a cell array and% returns a structure constructed from the cell array. The elements in% the odd indexes of the cell array should determine the field name and% the
Georgia Tech - CS - CS 1371
%=% Problem 2. Searching through a structure array%-%% Problem Statment:%% Write a function named structSearch that takes in a structure array, a% fieldname, and a value. The function should return a new structure% array containing ever
Georgia Tech - CS - CS 1371
function S = structSort2(A,str)a = A;b = A;[r c] = size(A);vec = [];if r = 1 a = A; [v loc] = minStruct(a,str); vec = [vec v]; a(loc) = [];else for x = 1:r for y = 1:c [v loc] = minStruct(b,str);
Georgia Tech - CS - CS 1371
%=% Problem 3, part B. Sorting the structure array%-%% Problem Statment:%% Write a function named structSort that takes in a structure array and a% string. The string specifies the name of a field in the structure% array that will only
Georgia Tech - CS - CS 1371
function [A B C D_rows D_cols E F G H I J] = ABCs_arrays(num1, arr1, arr2, i, j, arr3, arr4, arr5, vec1)% PROBLEM 3. THe ABCs of Arrays% This is a multi-part problem. Do each of the parts below.% % DO NOT CHANGE THE FUNCTION HEADER (the first lin
Georgia Tech - CS - CS 1371
function genStats(excel)[num str cell]= xlsread(excel);[row col]=size(cell);avg=mean(num,2);for x=2:row cell{x,col+1}=avg(x-1);endtotavg=mean(num);for y=2:col cell{row+1,y}=totavg(y-1);endcell{end,end}=mean(totavg);cell{1,end}='Aver
Georgia Tech - CS - CS 1371
%Write a function called myCSVread which takes in a filename and returns a%cell array containing the doubles and chars from the file. Each value%will be seperated by commas. This function should work as the reverse of%myCSVwrite.%Hint: str2num
Georgia Tech - CS - CS 1371
%Write a function called myCSVwrite which takes in a cell array of doubles%and chars and a filename, returns nothing but writes a file with each of the cells'%contents seperated by commas. The cell array may be two dimensional, you%should put eac
Georgia Tech - CS - CS 1371
% Write a function called snake that takes in an array and a number% indicating how many places to &quot;snake&quot; the array as described below.% Snaking the vector involves shifting the numbers down columns, and % appending the overflow onto the top of
Georgia Tech - CS - CS 1371
function numwords=wordCount(string)fh=fopen(string,'r');words=';count=1;while ischar(words); words=fgets(fh); [tk rest]= strtok(words); while ~isempty(rest) [tk rest]= strtok(rest); count=count+1; endend numwo
Georgia Tech - CS - CS 1371
%=% Problem 5. Plotting Simple Shapes%-%% Problem Statement:%% Write a function called plotPolygon that will take in two vectors of the same% length and have no outputs. The first vector will contain the x values for the% polygon and t
Georgia Tech - CS - CS 1371
%=% Problem 7. Plotting Pretty Colors%-%% Problem Statment:%% Write a function named plotRainbow that takes in the radius, and an% increment value. Starting at the initial radius, plot 6 semicircles to% create a rainbow. The order of
Georgia Tech - CS - CS 1371
%=% Problem 1. Signal Processing%-% After graduating from Georgia Tech with a 4.0 GPA, you easily get a job% with SETI (search for extra terrestrial intelligence)% as an extra-terrestrial signal analyst. One day, while you are% working on the
Georgia Tech - CS - CS 1371
%=% Problem 2. Finding the determinant of a matrix using recursion%-% % Problem Statement:%% Write a function called recurDet which takes in a square matrix and % returns the determinant of that matrix using recursion.%% Hint: Use
Georgia Tech - CS - CS 1371
%=% Problem 4. Recursive Math%-%% Problem Statement%% Write a function named recMod that takes in 2 numbers and% returns the remainder of the first number divided by the second number.% This function should use recursion to produce th
Georgia Tech - CS - CS 1371
%=% Problem 1. Finding the sum of a vector with recursion%-%% Problem Statement:%% Write a function called recurSum which takes in a vector and returns% the sum of that vector using recursion.% % Notes: % -You *must* use rec
Georgia Tech - CS - CS 1371
%=% Problem 6. Plotting a Slinky%-%% Problem Statment:%% Write a function named slinky which takes in a number r, which is the % number of revolutions, and a number n, which is the number of points.% Your function should then plot a 3D
Georgia Tech - CS - CS 1371
%=% Problem 3. Arrays and Recursion%-%% Problem Statment:%% Write a recursive function named sumRings that consumes an M by N array% and returns a vector of the sums of its rings of elements. Consider:% [1 1 1 1 1 1 1% 1 2
Georgia Tech - CS - CS 1371
%=% Problem 8. Designing a Tunnel.%-%% Create a recursive function, tunnel.m, that will take in three inputs: a% radius (r), and two scalars, x and y. Plot a circle using the% coordinates (x,y) as the center and the radius (r) as your radius. C
Agnes Scott College - MGMT - 303
Besanko &amp; Braeutigam Microeconomics, 3rd editionSolutions ManualChapter 2 Supply and Demand AnalysisSolutions to Review Questions1. Excess demand occurs when price falls below the equilibrium price. In this situation, consumers are demanding a
Agnes Scott College - MGMT - 303
Agnes Scott College - MGMT - 303
Agnes Scott College - MGMT - 303
1. 2. 3.4. 5.6.7.8.9.Ch. V What is the cost-minimizing level of output? a. Given a desired level of o/p, isoquants and isocosts provide information to determine o/p level. Cost min level of inputs/ a. Determined by point at which ratio of
Agnes Scott College - MGMT - 303
ACCT 245 BronsteinExercise 3-13b a. Contribution margin per unit = \$25 - \$7 = \$19 Break-even point in units = \$81,000 19 = 4500 Break-even point in dollars = \$25 x 4500 = \$ 112500 (Fixed cost + Desired profit) Contribution margin per unit = (\$81,
Agnes Scott College - MGMT - 303
Sales Rev. COGS_ Gross Margin Gen. Sales &amp; Admin Net Income Calculating % Change: (Alt. Measure Base Measure)/ Base Meas Assets = Equity Cash+Inv.+Manf.Eq+Off. Furn= Common Stock + Retained Earn Inc Stmnt Contr. Margin fmt: Var Cost pe
Agnes Scott College - MGMT - 303
Acct245 Bronstein 10amProblem 6-19B a. Overhead Cost Allocation Under ABCTotal \$934,000Mat. Hndlng Mach. Set. Product Facility Cost pool \$366,000 \$180,000 \$28,000 \$360,000 Cost drivers # of parts # Setups # units test Mach. Hrs. 1,220,000 90 1,4
Agnes Scott College - MGMT - 303
3212 E Morley Way Seattle, WA 98112425.208.5617 Erich.B.Anderson@gmail.comErich AndersonObjectiveTo obtain a fulfilling job that gives me the opportunity to interact daily with clients as well as represent the highest level of service that cli
Agnes Scott College - MGMT - 303
How Good Am I at Building and Leading a Team?InstrumentUse the following rating scale to respond to the 18 questions on building and leading an effective team: 1 = Strongly disagree 2 = Disagree 3 = Slightly disagree 4 = Slightly agree 5 = Agree 6
Agnes Scott College - MGMT - 303
GROUP COMPOSITION REPORT and CONTRACT The rules of the exercise:1. 2.No one may talk until all group members have finished reading The Rules of the Exercise. Once everyone on your group is finished reading the rules, your group should elect (or on
Agnes Scott College - MGMT - 303
CH X 1. Price: a. The amount of money charged for a product or service, or the sum of the values that a consumer exchanges for the benefits of having or using the product or service. b. Non-Price factors have become more important recently. c. Dynami
Agnes Scott College - MGMT - 303
ACCT 245 BronsteinExercise 9-8B Operating income Operating assets = ROI Operating income \$2,500,000 = 10% Operating income = Operating assets x ROI Operating income = \$2,500,000 x 10% = \$250,000 Operating income = Sales Expenses = \$5,000,000 Ex
Agnes Scott College - MGMT - 303
Lab Section Monday .Case Worksheet #1: Motivation and Incentive SystemsThis case worksheet is worth a total of 50 points and counts as 5% of your final course grade. It pertains to two readings: &quot;The Art of Motivation&quot; and &quot;The Best Laid Incen
Agnes Scott College - MGMT - 303
Math 102 HomeworkMath 112 Homework Fall 2007 HW # 1 Due Monday, October 1Read 1.1, 1.2, 1.3, 1.4Recommended: 1.1 # 1-3, 7-9, 11, 13-18, 21, 24-27, 29, 32-33 1.2 # 3, 11, 14, 16-25, 27-29, 31-32, 36-38, 41-42, 47, 50-56, 61-63, 75-76Required: 1.
Agnes Scott College - MGMT - 303
Issue Is it within Washington's jurisdiction to require International Shoe Company, a foreign-based corporation, to pay unemployment compensation statutory of employees in Washington? Rule A company is within the jurisdiction of a state if it does bu
Agnes Scott College - MGMT - 303
Greetings class, Wed, you are to do a paper that reflects on the transaction you have chosen to study. You did the paper on the categories. Now, look at your transaction thru the lense of what it takes to make a Legally Enforceable Contract. So far,
Agnes Scott College - MGMT - 303
Note: This nutrition debate is in chapter 16 on pages 610-11. Considering the potential benefits of calorie restriction, do you think it is worth following this type of diet? Remember you must discuss this issue fully, and provide authoritative facts
Agnes Scott College - MGMT - 303
Many stressed out people today have been told to take a 50 B Complex supplement (contains 50 mg of Vitamins B1, B2, B3, B6). Based on what you read, give the pros and cons of this recommendation. Your answer must cover a significant amount of the mat
Agnes Scott College - MGMT - 303
NEGOTIABLE INSTRUMENTS A negotiable instrument is a (1) written instrument, (2) signed by the maker or drawer of the instrument, (3) that contains an unconditional promise or order to pay (4) a fixed amount of money (with or without interest in a sp
Agnes Scott College - MGMT - 303
1.Week 1 Discussion Questions Chapter 1 A great manager must have good planning, organizing, leading, and controlling abilities. They must be motivated and be able to motivate others. A good manager also rethinks their approach to accommodate chang