Computes the sum of the elements of an input matrix a

Assignment Help MATLAB Programming
Reference no: EM132376585

Lab Assignment - Function

To keep in mind:

>>Unless otherwise indicated, your function should not print anything to the Command Window. Your function may be counted incorrect if it does.

>> Note that you are not required to use the suggested names of input variables and output variables, but you must use the specified function names.

1. One of the tedious tasks we do in Mathematics is solve equations manually. Why not write a MATLAB code to do it for us?

Write a function my_eqn_solver that takes two input arguments A (3x3 matrix) and B (3x1 vector) (as described below), in that order, and returns the solution matrix.

HINT: To solve the equation of the type:

A1X1 + A2X2 + A3X3 = B1
A4X1 + A5X2 + A6X3 = B2
A7X1 + A8X2 + A9X3 = B1

We first need to create two matrices
A1 A2 A3 B1 A = A4 A5 A6 and B = B2

A7 A8 A9 B3

Then,

C = A-1B or A\B gives you the solution vector C (3x1 vector). Remember, it is a matrix multiplication.

Example eq: X1 +2X2 + 3X3 = 1

-X1 + 2X3 = 0

X1 + 3X2 + X3 = 0

2. Write a function called even_index that takes a matrix, M, as input argument and returns a matrix that contains only those elements of M that are in even rows and columns. In other words, it would return the elements of M at indices (2,2), (2,4), (2,6), ..., (4,2), (4,4), (4,6), ..., etc. Note that both the row and the column of an element must be even to be included in the output. The following would not be returned: (1,1), (2,1), (1,2) because either the row or the column or both are odd. As an example, if M were a 5-by-8 matrix, then the output must be 2-by-4 because the function omits rows 1, 3 and 5 of M and it also omits columns 1, 3, 5, and 7 of M.

3. Write a function called mat_extract that takes two inputs: a matrix N and a scalar nonnegative integer n, in that order, where each dimension of N is greater than or equal to n. The function returns the n-by-n square array at the top right corner of N. This might look a
bit tricky, but it is worth scratching your head!

4. Write a function called sum_perimeter that computes the sum of the elements of an input matrix A that are on the "perimeter" of A. In other words, it adds together the elements that are in the first and last rows and columns. Note that the smallest dimension of A is at least 2.

Reference no: EM132376585

Questions Cloud

Describe a decision tree by using a business example : Describe a decision tree by using a business example. Please explain why the decision tree helps leaders make decisions. The response must be typed.
Influential methodology to study social systems : Agent-based modeling has been applied in many domains. Why are they becoming an influential methodology to study social systems?
What interview types did the person describe : What interview types did this person describe? For example, consider the screening, the selection, the group, the competitive, the panel.
Complete report of your research project : Summarize the future research directions based on the identified gaps - provide a complete report of your research project, that you chose in Assessment 3
Computes the sum of the elements of an input matrix a : EECS 138-MATLAB Programming-University of Kansas-US-Write a function called sum_perimeter that computes the sum of the elements.
Explain the short-term and long-term impact of this diabetes : Explain the Short-term and Long-term impact of this Diabetes Type#1 on patients. including effects of drug treatments. Be specific and provide Examples.
Describe the topic and identify two views on the issue : WRIT1001 Writing and Rhetoric: Academic Essays Assignment - Short Writing Tasks and Final Essay, The University of Sydney, Australia
Maintain a constant 6 percent growth rate : Afterwards, the company pledges to maintain a constant 6 percent growth rate in dividends forever. If the required return on the stock is 16 percent
How much does a share of preferred stock cost today : If the market requires a return of 4.3 percent on this investment, how much does a share of preferred stock cost today?

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd