% Chapter 5, Problem 5
function Ch_05_P_05
clear
clc
% 5-5 Write a function called myMin4 that will take in 4 numbers
% and returns the minimum value and an index showing which parameter
% it was. You may not use the built-in min() function. For exampl
% Chapter 9, Problem 5
function Ch_09_P_05
clear
clc
% 9-5 Create and test a function called recursiveMin that takes in a
% vector and returns the element with the minimum value and the index of
% that element as separate returned values, much as the sta
% Chapter 9, Problem 6
function Ch_09_P_06
clear
clc
% 9-6 Write a recursive function named sumRings that consumes an M by N
% array and outputs a vector of the sums of its consecutive rings. If the
% input array is a 1xN or Mx1 (row or column vector), f
% Chapter 11, Problem 1
function Ch_11_P_01
clear
clc
close all
% 11-1 Write a script that creates six sub-plots in two columns
% each with three rows. Each plot should have an appropriate title
% and labels on the x and y axes. The plot in the top lef
% Chapter 11, Problem 2
function Ch_11_P_02
clear
clc
close all
% 11-2 Your task is to create a script called thisPlot. This script
% should do the following:
% a. Ask the user to enter in a positive number, N, greater than 5.
% b. The script should the
% Chapter 11, Problem 3
function Ch_11_P_03
clear
clc
close all
% 11-3 Write a function called sineGraph that graphs a sine function
% four times between the interval [start,stop] on the same graph.
% The start and stop values should be parameters of
% Chapter 11, Problem 4
function Ch_11_P_04
clear
clc
close all
% 11-4 This programming problem will compare the surf() and mesh()
% functions by putting two 3-D side by side plots for comparison using
% subplot(). You should label all axes accordingly
% Chapter 11, Problem 5
function Ch_11_P_05
clear
clc
close all
% 11-5 Georgia Tech wants to tear down the Campanile and build a
% new one that is ridiculously tall. However, before they build it,
% they need you to model it in MATLAB. Using the equat
% Chapter 11, Problem 7
function Ch_11_P_07
clear
clc
close all
% 11-7 You just realized that February 14th has passed and you haven't
% gotten anything for your Valentine. Since your date is a CS major,
% sending the lucky person a MATAB coded heart w
% Chapter 12, Problem 1
function Ch_12_P_01
clear
clc
% This is a set of simple matrix manipulations.
% a. Create a five by six matrix, A, that contains random numbers
% between 0 and 10.
A = 10*rand(5, 6)
% b. Create a six by five matrix, B, that conta
% Chapter 12, Problem 2
function Ch_12_P_02
clear
clc
% 12-2 World Leaders have decided to come up with a single currency for
% the world. This new currency called the Eullar is defined by the
% following:
% Seven Dollars and three Euros make seventy-one
% Chapter 9, Problem 4
function Ch_09_P_04
clear
clc
% 9-4 Create a recursive function with a wrapper to protect it from
% illegal values. The function name should be recursiveFib. It should takes
% in a number n and returns the nth Fibonacci number. You
% Chapter 9, Problem 3
function Ch_09_P_03
clear
clc
% 9-3 Consider the problem of structures with nested fields.
% a. Write a function called tracker that takes in a structure and
% returns the number of levels at which it has a field called 'Inner'. Ea
% Chapter 5, Problem 6
function Ch_05_P_06
clear
clc
% 5-6 Write the function meansAndMedian which takes in a vector of
% numbers and returns the arithmetic and geometric means, as well as
% the median. You may not use the built-in functions mean(), me
% Chapter 5, Problem 7
function Ch_05_P_07
clear
clc
% 5-7 Given an array of numbers that could be negative, write a
% function posavg(a) to calculate and return the average (mean) of
% the nonnegative numbers in the single dimensional array,
% a. One
% Chapter 5, Problem 8
function Ch_05_P_08
clear
clc
% 5-8 Write a function called sumAndAverage. It should take in an
% array of numbers and return the sum and average of the array in that
% order. For example:
[s a] = sumAndAverage([3 2 3 2]) hould r
% Chapter 5, Problem 10
function Ch_05_P_10
clear
clc
% 5-10 Write a function called multiSum(A). This particular function
% should take in a N M array, A, and return four results:
% A 1 M vector with the sum of the columns,
% A N 1 vector with the sum
% Chapter 5, Problem 11
function Ch_05_P_11
clear
clc
% 5-11 You are playing a game where you roll a die 10 times.
% If you roll a five or six seven or more times, you win 2 dollars,
diceGame([5 1 4 6 5 5 6 6 5 2]) hould return 2
diceGame([2 4 1 3 6 6
% Chapter 6, Problem 1
function Ch_06_P_01
clear
clc
% 6-1 Solve the following introductory problems on strings.
% a.Write a function dayName that consumes a parameter, day, containing the
% numerical value of a day in the month of September 2008. Your f
% Chapter 6, Problem 3
function Ch_06_P_03
clear
clc
% 6-3 Write a function called DNAcomplement that consumes a set of
% letters as a character array that form a DNA sequence such as 'gattaca'.
% The function will produce the complement of the sequence
% Chapter 6, Problem 4
function Ch_06_P_04
clear
clc
% 6-4 The function rot(s, n) is a simple Caesarcipher encryption
% algorithm that replaces each English letter in places forward or backward
% along the alphabet in the strings. For example, the result
% Chapter 9, Problem 1
function Ch_09_P_01
clear
clc
% 9-1 For this problem you will be required to write three functions -
% recurSum, recurProd and fibVector. The first one will take in a vector
% and compute the sum of the elements of the vector. The
% Chapter 9, Problem 2
function Ch_09_P_02
clear
clc
% 9-2 Write a recursive function called oddfact(n) which takes in a
% number and returns the factorial of the odd numbers between the given
% number and 1. For example:
oddfact(4) %returns 3
oddfact(
% Chapter 12, Problem 3
function Ch_12_P_03
clear
clc
% 12-3 Write a function called determinant. This function will take in a
% 3 x 3 matrix of numbers and return the determinant of the matrix. The
% formula for the determinant of a 3 x 3 matrix is as f
% Chapter 12, Problem 4
function Ch_12_P_04
clear
clc
% 12-4 As the enthusiastic and motivated student that you are, you decided
% to go out and buy plenty of pens for all your classes this semester. This
% spending spree occurred at the unfortunate time
% Chapter 12, Problem 5
function Ch_12_P_05
clear
clc
% 12-5 Write a function called rotateLine that takes in two vectors, x and
% y, of the same length that represent a set or ordered pairs that could be
% used to plot a line. Your function should also
function mcd=euclid(m,n)
% Algoritmo di euclide: calcola il MCD dei
% suoi argomenti.
% Gli argomenti devono essere interi non negativi.
if (m ~= floor(m) | (m < 0) | (n ~= floor(n) | (n < 0)
fprintf('Euclid richiede due interi positivi! \n');
m
n
function m=fattoriale(n)
% m = n!
if (n ~= floor(n)| (n<0)
disp('Errore: input non intero')
m=0;
return
end
m=local_fact(n,1);
end
function res=local_fact(m,n)
if (m=0)
res=n;
else
res=local_fact(m-1,m*n);
end
end
function [mx,ix]=iamax(v)
% Return the max val of a vector and its position
mx=0;
ix=0;
for i=1:length(v)
if (abs(v(i) >= mx)
mx = v(i);
ix = i;
end
end