Explore BrainMass
Share

Matlab Functions: Two Row Vectors as Inputs

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Write a Matlab function that will accept two row vectors (A and B) as inputs. The function computes the row vector C that is the term-by- term product of A and B (that is, C1= A1*B1, C2=A2*B2, and so on), and that then computes the values of the function sin(x) for each value of C and stores these values in the row vector D. The outputs of the program are the arrays C and D.

For demonstration of the function, the array A and B are:
A = 1.2, 3.5, 6.7, 8.3, 0.9, 4.2
B = 0.5, 1.0, 0.08, 0.2, 1.3, 0.85

© BrainMass Inc. brainmass.com October 16, 2018, 9:02 pm ad1c9bdddf
https://brainmass.com/engineering/mechanical-engineering/matlab-functions-two-row-vectors-inputs-169543

Solution Preview

I attached two files.

"Term_by_term.m" contains the requested function. It checks that the ...

Solution Summary

This solution provides guidelines on how to write a Metlab function that will accept two row vectors as inputs.

$2.19
Similar Posting

MATLAB Convolution Simulation

Write and verify a computer program to perform the convolution of two discrete signals.

[1] The convolution program should be written as an m-file able to handle two general discrete signals. The M-file will be ain function file format, it will take two inputs sin1, sin2, and return an output sout.

sin1, sin2: can be row or column vectors of any length
sout: will be a row vector (length is determined by input vectors)

Ex:
function sout=convolution(sin1,sin2)
{
%put your code here with comments
}
2. Test with the following signals:
(Plot all results -> use the stem command)

Case 1:
h(n)=1 for 1<n<4
x(n)=1 for 1<n<4
Case 2:
h(n)=1 for n=1,2,...10
x(n)=(1/2)^n-1 for n=1,2,...20

All functions equal zero in regions not defined above. Use MATLAB conv function to verify your program.

3. Similiar to convolution is an operation known as correlation. This operation is used in signal analysis to determine the similiary between two signals. Explore the functionality of correlation through the use of MATLAB xcorr command. Plot the results of xcorr for the two cases provided above. What is the relationship of correlation to convolution?

To me it seems that convolution is autocorrelation because I worked an example by hand. Please comment the program so that I can see how it is done. Thank you.

View Full Posting Details