Question

In: Electrical Engineering

Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...

Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution.

Generate the following vectors and also implement the Table-1 operations-map by employing the switch statement and an appropriate loop.

  • Generate a vector ‘DEC1’ as follow.

DEC1 =

5     1     3     0     2    5     0     2

  • Concatenate vector ‘DEC1’ eight times in order to obtain a bigger row vector ‘DEC’
  • N = The length of vector DEC
  • Generate a vector t with ‘N’ equally spaced values within the range of 0 to 1
  • x = round of 26sin(2π9t).
  • y = ‘x’ multiply by 2.

Table-1

DEC(ind)

Operation

0

Res(ind)= x(ind) multiply by y(ind)

1

Res(ind)= x(ind) divided by y(ind)

2

Res(ind)= square root of [x(ind).y(ind)]

3

Res(ind)= x(ind) subtract from y(ind)

5

Res(ind)= x(ind) add to y(ind)

* In Table-1, ind is presenting the vector index.

Solutions

Expert Solution

The Matlab Code is as follows:

DEC1=[5 1 3 0 2 5 0 2]       % Generates the vector DEC1 with the given values
DEC = [DEC1 DEC1 DEC1 DEC1 DEC1 DEC1 DEC1 DEC1]   %Concatenate the 'DEC1' 8 times to obtain 'DEC'
N = length(DEC)   % Finding length of vector 'DEC'
t = 0:(1/N):1   %Generating vector t with 'N' equally spaced values within the range of 0 to 1
x = round(26*sin(2*pi*9*t))       % round off the result of 26sin(2pi9t)
y=x*2   % y = 'x'multiply by 2
%For loop for defining Table1 ind values 0 1 2 3 4 5
for ind=0:5
switch ind
   % the index of vector is positive in matlab
   case 0    % for ind = 0
       Res(ind+1)=x(ind+1)*y(ind+1)           % first element
   case 1   % for ind = 1              
       Res(ind+1)=x(ind+1)/y(ind+1)           % second element
   case 2   % for ind = 2              
       Res(ind+1)=sqrt(x(ind+1)*y(ind+1))       % third element
   case 3   % for ind = 3              
       Res(ind+1)=y(ind+1)-x(ind+1)            % fourth element
   case 5   % for ind = 5              
       Res(ind+1)=x(ind+1)+y(ind+1)           % sixth element
end
end

Output:

DEC1 =

   5   1   3   0   2   5   0   2

DEC =

 Columns 1 through 20:

   5   1   3   0   2   5   0   2   5   1   3   0   2   5   0   2   5   1   3   0

 Columns 21 through 40:

   2   5   0   2   5   1   3   0   2   5   0   2   5   1   3   0   2   5   0   2

 Columns 41 through 60:

   5   1   3   0   2   5   0   2   5   1   3   0   2   5   0   2   5   1   3   0

 Columns 61 through 64:

   2   5   0   2

N = 64
t =

 Columns 1 through 8:

         0    0.0156    0.0312    0.0469    0.0625    0.0781    0.0938    0.1094

 Columns 9 through 16:

    0.1250    0.1406    0.1562    0.1719    0.1875    0.2031    0.2188    0.2344

 Columns 17 through 24:

    0.2500    0.2656    0.2812    0.2969    0.3125    0.3281    0.3438    0.3594

 Columns 25 through 32:

    0.3750    0.3906    0.4062    0.4219    0.4375    0.4531    0.4688    0.4844

 Columns 33 through 40:

    0.5000    0.5156    0.5312    0.5469    0.5625    0.5781    0.5938    0.6094

 Columns 41 through 48:

    0.6250    0.6406    0.6562    0.6719    0.6875    0.7031    0.7188    0.7344

 Columns 49 through 56:

    0.7500    0.7656    0.7812    0.7969    0.8125    0.8281    0.8438    0.8594

 Columns 57 through 64:

    0.8750    0.8906    0.9062    0.9219    0.9375    0.9531    0.9688    0.9844

 Column 65:

    1.0000

x =

 Columns 1 through 16:

    0   20   26   12  -10  -25  -22   -3   18   26   14   -8  -24  -23   -5   16

 Columns 17 through 32:

   26   16   -5  -23  -24   -8   14   26   18   -3  -22  -25  -10   12   26   20

 Columns 33 through 48:

    0  -20  -26  -12   10   25   22    3  -18  -26  -14    8   24   23    5  -16

 Columns 49 through 64:

  -26  -16    5   23   24    8  -14  -26  -18    3   22   25   10  -12  -26  -20

 Column 65:

    0

y =

 Columns 1 through 16:

    0   40   52   24  -20  -50  -44   -6   36   52   28  -16  -48  -46  -10   32

 Columns 17 through 32:

   52   32  -10  -46  -48  -16   28   52   36   -6  -44  -50  -20   24   52   40

 Columns 33 through 48:

    0  -40  -52  -24   20   50   44    6  -36  -52  -28   16   48   46   10  -32

 Columns 49 through 64:

  -52  -32   10   46   48   16  -28  -52  -36    6   44   50   20  -24  -52  -40

 Column 65:

    0

Res = 0
Res =

        0   0.5000

Res =

         0    0.5000   36.7696

Res =

         0    0.5000   36.7696   12.0000

Res =

         0    0.5000   36.7696   12.0000         0  -75.0000

Related Solutions

Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Develop three functions for temperature-conversion. Create a function called F_to_K that converts and return temperatures in Fahrenheit to Kelvin and store results in ‘F_to_K2.txt’. Create a function called C_to_R that converts and return temperatures in Celsius to Rankine and store results in ‘C_to_R2.txt’. Create a function called C_to_F that...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Write a user defined function ‘My_FunctionGen’. It accepts, the time vector ‘t’ with 8000 uniformly spaced values within the range of 0 to 8, Frequecy scalars ‘f1<100H’ and ‘f2<80Hz’ and Amplitude scalars ‘A1’, ‘A2’ and ‘A3’ as input arguments. It delivers x1, x2 and x3 and x4 as outputs...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Develop three functions for temperature-conversion. Create a function called F_to_K that converts and return temperatures in Fahrenheit to Kelvin and store results in ‘F_to_K2.txt’. Create a function called C_to_R that converts and return temperatures in Celsius to Rankine and store results in ‘C_to_R2.txt’. Create a function called C_to_F that...
this is my matlab code for class, my professor commented "why is the eps an input...
this is my matlab code for class, my professor commented "why is the eps an input when it is set inside the function and not specified as a variable? how do i fix? function[] = () %Declare Global Variables global KS; global KC; KC = 0; KS = 0; End = 0; while (End == 0) choice = questdlg('Choose a function', ... 'Fuction Menu', ... 'A','B','B'); switch choice; case 'A' Program = 'Start'; while strcmp(Program,'Start'); Choice = menu('Enter the Trigonometric...
Use Matlab to write the following 1. Write code to determine whether a year is a...
Use Matlab to write the following 1. Write code to determine whether a year is a leap year. Use the mod function. The rules for determining leap years in the Gregorian calendar are as follows: All years evenly divisible by 400 are leap years. Years evenly divisible by 100, but not by 400, are not leap years. Years divisible by 4, but not by 100, are leap years. All other years are not leap years. For example, the years 1800,...
Write a matlab code to do following steps; i) Record your voice by sampling frequency 22...
Write a matlab code to do following steps; i) Record your voice by sampling frequency 22 kHz ii) Down sample the voice by 2 listen to your voice iii) Down sample the voice by 3 listen to your voice Please explain the code clearly. Thank you.
write the code in MATLAB with comments and show the inputs and results of the code...
write the code in MATLAB with comments and show the inputs and results of the code for the question below. Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds that was recorded using your phone), then take Fourier transform of the signal (probably FFT).
QUESTION You are required to obtain a copy of a financial report for STRATEGIC ENERGY RESOURCES...
QUESTION You are required to obtain a copy of a financial report for STRATEGIC ENERGY RESOURCES LIMITED for the year ended 30 June 2019. The best way to locate their financial report is to go to their website and download a copy. This will normally be found under “Investor Information”, “Shareholder Information” or similar tabs on a company’s website. REQUIRED 1)  Identify and explain three key or significant audit matters that were raised in the audit report that may lead to...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds), takes Fourier transform of the signal (probably FFT).
write a matlab code to simulate fiber optics communication system on matlab simulink
write a matlab code to simulate fiber optics communication system on matlab simulink
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT