{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Unit10 Lab A

# Unit10 Lab A - 7-A.4 function anArray = Prob7_A_4 creates...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 7-A.4 function anArray = Prob7_A_4 % creates the array given in the problem definition % INPUTS: None % OUTPUT: the array given in Problem 7-A.4 anArray = [7:7:42; 6:-2:-4; 44:11:99; -9:4:11; 61:-25:-64]'; 7-A.10 function anArray = prob7_A_10(anArray) % sets the corners of the input array to 99 % INPUT: An n by m array % OUTPUT: The modified n by m array anArray(1,1)=99; anArray(1,end)=99; anArray(end,1)=99; anArray(end,end)=99; %or... %anArray([1,end],[1,end])=99 % or... % [n,m] = size(anArray); % anArray([1,n,n*(m-1)+1,n*m])=99; 7-A.12 function anArray = Prob7_A_12(anArray) % reverses the order of elements in the second column % of the input array % INPUT: An n by m array % OUTPUT: An n by m array anArray(:,2) = anArray(end:-1:1,2); 7-A.16 function solnVector = Prob7_A_16 % Solves the system of equations: % 2x+5y+z=12 % x+2y-3z=5 % x-y+z=-1 % INPUTS: None % OUTPUT: A column vector of [x; y; z] A = [2 5 1;1 2 -3; 1 -1 1]; B = [12; 5; -1]; solnVector = A\B; 7-A.17 function solnVector = Prob7_A_17 % Solves the system of equations: % x+y-z=6 % 2x-y+2z=3 % 3x+2y+5z=35 % INPUTS: None % OUTPUT: A column vector of [x; y; z] A = [1 1 -1; 2 -1 2; 3 2 5]; B = [6; 3; 35]; solnVector = A\B; 7-A.18 function solnVector = Prob7_A_18(V, coeff) % solves linear system of equations % INPUTS: A vector of the right hand-side values V % An array of system coefficients coeff % such that: % coeff*X = V % OUTPUT: The solution in a column vector solnVector = coeff\V; 7-A.19 function [locations, values] = Prob7_A_19(anArray) % finds the indices and values of the elements in an array % that are less than zero % INPUT: An array % OUTPUTS: An nx2 array of indices % An nx1 vector of values [locationRow locationCol] = find(anArray<0); locations = [locationRow locationCol]; values = anArray(find(anArray<0)); ...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

Unit10 Lab A - 7-A.4 function anArray = Prob7_A_4 creates...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online