Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a function, called multGauss, to compute the sum of multiple Gaussian (normal) profiles. See the figure here to illustrate what Gaussians of different

image text in transcribed
1. Write a function, called multGauss, to compute the sum of multiple Gaussian (normal) profiles. See the figure here to illustrate what Gaussians of different locations, amplitudes and 'widths' (standard deviations) look like. The function should itself call the function gaussmf (built-in matlab function) to do the basic calculation, returning only the sum (i.e., add together the individual Gaussian profiles). The function multGauss that you write should be able to handle any number of requested Gaussians (say 2, 4, 10, whatever). The easiest way to determine the number of requested Gaussians might be from the number of rows in an input input to the function) matrix, beta, each of which contains the parameters of each component Gaussian. Include error checking to ensure that the input parameter matrix has three columns, returning an error if not. To clarify, the inputs to multGauss should be (i) an input matrix with three columns (see help on gaussmf, the third parameter is simply the amplitude (default is 1) of the Gaussian) for the parameters and at least one row (cach row being an individual Gaussian; (ii) a vector x specifying the domain for the calculations. The output from multGauss is a vector that gives the sum of the Gaussians at each location x in the domain. 2. Write an m-file called mygauss.m that defines the input variables, issues a call to multGauss and plots the result. Let the domain range from 0 to 20. Let there be four Gaussians. The amplitudes are to be 0.1, 0.5, 1, and 2. The standard deviations (sigma) are to be 0.5, 1, 2 and 3. The positions are to be 2, 4, 6, and 8. 3. Write an m-file called sumrand.m to calculate the mean of a random number sequence generated with the command data - rand(10000,1). Your mfile should have two parts. In the first part, use for loops and the following equation In other words, old-school programming. You may NOT use the mean function. You MUST use programming structures. The second part of your m-file should do the same calculations using the built-in matlab function mcan. Hint: this part is ridiculously easy (one line) 4. Repeat 4 with a slight variation, and call it sumrandconditional.m. You want to compute the mean only on the numbers that are greater than 0.5. Again, do it old- school style, with for and if loops. Then, do it with matlab niceties. Find command, clever indexing, and so on. Use the disp command to output results to the screen. 1. Write a function, called multGauss, to compute the sum of multiple Gaussian (normal) profiles. See the figure here to illustrate what Gaussians of different locations, amplitudes and 'widths' (standard deviations) look like. The function should itself call the function gaussmf (built-in matlab function) to do the basic calculation, returning only the sum (i.e., add together the individual Gaussian profiles). The function multGauss that you write should be able to handle any number of requested Gaussians (say 2, 4, 10, whatever). The easiest way to determine the number of requested Gaussians might be from the number of rows in an input input to the function) matrix, beta, each of which contains the parameters of each component Gaussian. Include error checking to ensure that the input parameter matrix has three columns, returning an error if not. To clarify, the inputs to multGauss should be (i) an input matrix with three columns (see help on gaussmf, the third parameter is simply the amplitude (default is 1) of the Gaussian) for the parameters and at least one row (cach row being an individual Gaussian; (ii) a vector x specifying the domain for the calculations. The output from multGauss is a vector that gives the sum of the Gaussians at each location x in the domain. 2. Write an m-file called mygauss.m that defines the input variables, issues a call to multGauss and plots the result. Let the domain range from 0 to 20. Let there be four Gaussians. The amplitudes are to be 0.1, 0.5, 1, and 2. The standard deviations (sigma) are to be 0.5, 1, 2 and 3. The positions are to be 2, 4, 6, and 8. 3. Write an m-file called sumrand.m to calculate the mean of a random number sequence generated with the command data - rand(10000,1). Your mfile should have two parts. In the first part, use for loops and the following equation In other words, old-school programming. You may NOT use the mean function. You MUST use programming structures. The second part of your m-file should do the same calculations using the built-in matlab function mcan. Hint: this part is ridiculously easy (one line) 4. Repeat 4 with a slight variation, and call it sumrandconditional.m. You want to compute the mean only on the numbers that are greater than 0.5. Again, do it old- school style, with for and if loops. Then, do it with matlab niceties. Find command, clever indexing, and so on. Use the disp command to output results to the screen

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions