Create a loop for each parameter in the magnitude vector

Assignment Help MATLAB Programming
Reference no: EM131352754

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);

Reference no: EM131352754

Questions Cloud

Name the properties of solids : Name the properties of solids that are little affected by the presence of small concentrations of chemical impurities. Name the properties of solids that are greatly affected by the presence of small concentrations of chemical impurities.
How you have integrated effective literacy components : How you have integrated effective literacy components within each learning environment; and Rationale for choosing and arranging the objects in each classroom model.
Why do impurities not affect the resistivity of insulators : Explain. Many insulators, however, are not very pure. Why do impurities not affect the resistivity of insulators?
Ability of human beings to modify the genomes : Identify some advantages and problems associated with genetically modified Bt corn. Should we put a limit on the ability of human beings to modify the genomes of other living things?
Create a loop for each parameter in the magnitude vector : Create a loop for each parameter in the magnitude vector and 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.
How the teacher has set up the classroom : When a student enters into the classroom door they should feel the excitement as well as look around and see how the teacher has set up the classroom.
Discuss the diversity implications that are involved : Sometimes students have trouble finding or picking an article. You might try a search that includes some common ethical issues in the search terms. For example: informed consent, confidentiality, dual relationships, etc. Make sure that the issue..
Why are metallic solids mostly opaque : Explain why metallic binding leads to a close-packed arrangement of atoms; i.e., explain why the lowest energy in metallic binding corresponds to the greatest number density of atoms.
Concepts and connections first canadian edition : Human babies that are heavier than average and lighter than average have a higher infant mortality. What type of selection (be specific) is this and why? Textbook is campbells Concepts and connections first Canadian edition.

Reviews

len1352754

1/13/2017 1:39:59 AM

This is an introduction lab to my new class. VERY BASIC I need only one person who can help me with this class. I will start with for this assignment and will increase the price for the next one. PLEASE I do not want any more bargaining in this course so I can set a weekly budget for your help.

Write a Review

MATLAB Programming Questions & Answers

  Programming application that can be written in mat lab

Chose topic in programming application that can be written in Mat Lab code

  Control system introduction

You are required to develop a controller for a simple robotic arm with payload. As shown in the figure, the system is composed of the dc motor driving a single arm.

  Programme for easter island simulation

The "RATS" program code is given and even if the person does not know RATS, it is very similar so should be able to figure it out.

  Write a program to implement this process

A computer cannot store an entire function in its memory. Typically it stores the values of the function at a finite number of points. Pick values of a, b, v, N, and Δt, and write a program to implement this process. Be sure to leave a, b, v, N, an..

  Determine the true displacements using the true weights

Matlab Three masses are attached to spring, k1 = 30 N/m, k2 = 25N/m, k3 = 20N/m, and k4 = 15N/m, as shown. Initially the masses are positioned such that the springs are in their natural length (not stretched or compressed); then the masses are slo..

  Develop mathematical equations for the motor system

Develop mathematical equations for the motor system to relate the input voltage to armature current, shaft speeds (including main shaft's speed and gearbox's speed) and angular displacement

  Realistic animations include more

Realistic animations include more than just translations of shapes. They also have scaling involved. For this question, you're asked to write a function called "problem4" that accepts a single input variable and applies a scaling constant of 3. Th..

  Determine the optimal linear predictor

Determine the optimal linear predictor for a given order N and DPCM simulation and write a graphical user interface that has least the following functions

  Considered to equal when the result of one array subtract

Two arrays are considered to be equal when the result of one array subtracted from the other is an array of zeros. In the script file, create the MATLAB commands to prove the following relationships (use arrays that you makeup yourself)

  Create a matrix of 5x6

Prepare a matrix of 5x6. with identical columns and rows ranging from 200 to 1000 in equal increments

  Develop a simulation program

Develop a simulation program

  Matlab program to calculate the rest of the coefficients

Step One: For the design specifications of your filter, see the excel file for specifications (UDO). You need to demonstrate for the first two iterations( n=0 & n=1), by hand, the calculation of the coefficients. Step Two: Develop a Matlab prog..

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