Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The built-in MATLAB function sum calculates and returns the sum of array elements. syntax is S= sum(mat, dim), where not stores a matrix and dim

image text in transcribed

The built-in MATLAB function sum calculates and returns the sum of array elements. syntax is S= sum(mat, dim), where not stores a matrix and dim is the dimension to sum over (dim= 1 for the column sum while dim= 2 for the row sum). Please see and try the example below: The >> mat= [1-230.5; 68.3-9 1] mat = 1.0000 -2.0000 3.0000 0.5000 6.0000 8.3000 9.0000 1.0000 >> colsum= colsum- sum (mat, 1) 6.3000 -6.0000 >> rowsum sum (mat,2) rows um = 2.5000 6.3000 a) (8 pts) Now it is time to write your own user-defined MATLAB function named sumprint that will prompt the user to input a matrix, then calculate and output the row sum and the column sum (similar to the results obtained by using the built-in MATLAB function sum) b) (2 pts) In the main MATLAB script, call and test your function sumprint. Notes: . You are not allowed to use the built-in MATLAB function sum. Instead, you can use built-in function sum to compare results with the ones obtained from your user defined function sumprint. The format of the output should be as specified below: Please input a matrix: [1 -2 3 0.5 6 8.3 -9 1] The inputted matrix is: 2.0000 3.0000 0.5000 1.00002 6.0000 8.3000 -9.0000 1.0000 The sum of each column is: 7.0000 6.30006.0000 1.5000 The sum of each row is: 2.5000 6.3000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

Students also viewed these Databases questions