Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

1) Write a function, called SuperPos,m, that will take four variables as arguments and return two output values. The first will be a time row-vector, t, the second a magnitude vector, mag, the third a phase vector, phase, and the fourth, a string vector, waveFormType, containing either 'c' or 's'. The last three vectors are required to be the same size.

The function should return a vector, y that is the same size as t, and return a vector, T, that is exactly t.

You must add appropriate comments at the beginning of your function (Description, Inputs, Outputs, written by, and date). See the example in the MATLAB introduction provided.

Define a function variable: freq = 10; This parameter will be used within the function, but not passed into or out of the function.

Allocate the memory for a (m x n,) matrix, Y, where m is the # of parameters in mag, and n is the number of parameters in t. i.e. Y = zeros(m, n); You will need to determine m & n using the MATLAB length command.

2) Write a vector For-Loop that does the following.

- Before the for-loop, create a figure, and make sure MATLAB holds the plot. flgumjgacton;

- Create a loop for each parameter in the magnitude vector. i.e. "for ii = 1:length(mag)"

- Calculate the required phase using a if-then-else condition check. i.e. "if waveFormType(ii) == 's' then phi = phase(ii)-pi/2;
"else" phi=phase(ii); Do not forget to structure this if-then-else properly. If you are having trouble, do a "help if" at the MATLAB command line prompt.

Comment on what "ii" is doing in this section and how the if-then-else loop works.

- Now calculate ith row vector of Y, by taking mag(ii), the phi you determined previously, the passed parameter t, the 2*pi*freq.

Hint: You will need to use either y(ii,:)= or Y(:,ii)=,

Comment on what Y(ii,:).= and Y(:,ii)= expect for a calculated parameter (specifically: how many rows and columns does each want)

- Plot your newly calculated row-vector versus t. Make sure each new row-vector plot is on the same graph.
- end yag,for-loop properly.
- Finally, label the x-axis, y-axis, include a title, and your full name using the text command.

Copy your figure to your worksheet.

3) Next, calculate the superposition of each row-vector. You can do this with another for loop, but that is a bad way to do it. MATLAB is a matrix based programming language and all of its commands are written to work on matrices.

Do a "help sum" at the MATLAB command line prompt. Follow the instructions to have the sum command sum down the column of your Y matrix and equate this sum to the return parameter y. i.e. y.,s,m,(,Y ...);, where the ... are what you need to figure out.

Finally, equate T=t for the last return parameter and ensure your function ends properly

4) Call this function from the Lab1 M-File using the following parameters. Note: It is the location of the variable name in the function, and not the name that matters when passing parameters to a function.

tt: row-vector starting at 0, ending at 0.5, and having a step size of 0.003. MM = [1; 0.5; 3]; %The magnitude values Phi = [pi/4; pi/3; 0]; % The phase values Sinusoid = ['s';'c','s'l; %s is a sin function, c is a cos function. Spaces in the string matter, because the % parameters must be the same length on each row!

For the return parameters, use r and then p. These are bad names, because they don't mean anything and not good programming technique, but they make the point about the names being independent.

[r, p] = SuperPos(tt, MM, Phi, Sinusoid);

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M92165638
  • Price:- $65

Guranteed 36 Hours Delivery, In Price:- $65

Have any Question?


Related Questions in MATLAB

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignment -we have daily gridded rainfall data of 40 years

Assignment - We have daily gridded rainfall data of 40 years and structure of the dataset is like below; Lat = [6.5:0.25:38.5]; Lon = [66.5:0.25:100]; Rainfall (135x129x365x40) (Lon, Lat, days, years). Now, we looking fo ...

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As