Question

9. Write a MATLAB function with the following specifications: a) Input parameter 1: A b) Input parameter 2: B c) Input parameter 3: C d) Input parameter 4: D e) Output parameter: Sum of the input parameters f Time interval -2T St S2T g) Waveform 1 to plot: y(t) Asin BOt-c0) +D h) Waveform 2 to plot: yon-Acos(Bor-c)+D Display two plots in vertical fashion on one figure j) Include all labeling on both plots. k) Add a grid to both plots. Include Help comments m) Include comments in the body of the code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

x=(t-C); %copy the value of t-C into x

y=(t-B); %copy the value of t-B into y

z=sum(A,B,C,D); %to evaluate sum of A,B,C,D

w=times(A,sin(B,x)); %times is a method used for multipling two values(A,sin(B,x))

v=times(A,cos(B,x)); %times is a method used for multipling two values(A,cos(B,x))

w1=sum(w,D); %to evaluate sum of w and D

w2=sum(v,D); %%to evaluate sum of v and D

fprintf('%i\n',z); % fprintf is used to print content

fprintf('%i\n',w1);

fprintf('%i\n'w2);

grid_rectangular.w1; %grid_rectangular method is used to prinnt int rectangular format

grid_rectangular.w2;

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB function with the following specifications: Input parameter 1: A Input parameter 2: B...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a Matlab function, piecewise (), that will calculate and return the value of the...

    1. Write a Matlab function, piecewise (), that will calculate and return the value of the function f(x) defined by: 0<rS3 3<s5 e (x) -cos(3r) 2 sin(r) 2. Write a Matlab script to plot the function f(z) on the interval -3ss8. Ensure the output is sufficiently smooth by declaring z with enough data points. The plot should include the title My Piecewise Function, appropriate axis labels and grid lines. 1. Write a Matlab function, piecewise (), that will calculate and...

  • 1. (a) Evaluate the Fourier coefficients a, an, ba for the function defined as f)-2 cos() for-π/2...

    1. (a) Evaluate the Fourier coefficients a, an, ba for the function defined as f)-2 cos() for-π/2 s sn2 and zero else over the period of 2T, do NOT use MATLAB or a calculator for integrations. All the steps should be shown. Write a few terms of the Fourier series expansion Plot 2 or 3 cycles of the Fourier series using MATLAB and verify whether the plot matches the given waveform Find Co and Cn and plot the amplitude spectrum...

  • PLEASE USE MATLAB this problem you are trying to find an approximation to the periodic function /(t) esint-1) over one period, o <t < 2π. In t-linspace(0,2*pi,200)' and let b be a column ve...

    PLEASE USE MATLAB this problem you are trying to find an approximation to the periodic function /(t) esint-1) over one period, o <t < 2π. In t-linspace(0,2*pi,200)' and let b be a column vector of evaluations of f at those points. (a) Find the coefficients of the least squares fit In MATLAB, let (b) Find the coefficients of the least squares fit f(t)ndy+d2 cos(t)+ d, sin(t)+d, cos(2t)+dy sin(2t). (c) Plot the original function f(t)and the two approximations from (a) and...

  • Signals and System: MATLAB code provided? Begin with the MATLAB script named lab4.m as follows. You...

    Signals and System: MATLAB code provided? Begin with the MATLAB script named lab4.m as follows. You will modify this example code to cover each of the parts of this lab. You must always carefully document and include appropriate comments in any MATLAB code. & starting point for Lab#4 % LAPLACE TRANSFORM %---------- clear all; close all; -------------------- s = tf('s'); sys = 1/(5+1); & define H(s) for a dynamic system named sys ---------------- figure(1); bode (sys); % plot magnitude and...

  • MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax...

    MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax T(i)=t; if t>=(T0/2) while (t>T0/2) t=t-T0; end elseif t<=-(T0/2) while (t<=-T0/2) t=t+T0; end end if abs(t)<=(T0/4) y(i)=1; else y(i)=0; end i=i+1; end plot(T,y),grid, xlabel('Time (sec)'); title('y(t) square wave'); shg disp('Hit return..'); pause %--- a0=1/2; F(1)=0; %dc freq C(1)=a0; for n=1:Nmax a(n)=(2/(n*pi))*sin((n*pi)/2); b(n)=0; C(n+1)=sqrt(a(n)^2+b(n)^2); F(n+1)=n*f0; end stem(F,abs,(C)), grid, title(['Line Spectrum: Harmonics = ' num2str(Nmax)]); xlabel('Freq(Hz)'), ylabel('Cn'), shg disp('Hit return...'); pause %--- yest=a0*ones(1,length(T)); for n=1:Nmax yest=yest+a(n)*cos(2*n*pi*T/T0)+b(n)*sin(2*n*pi*T/T0);...

  • To plot a figure of a function y=f(t) in an interval a and b in MATLAB,...

    To plot a figure of a function y=f(t) in an interval a and b in MATLAB, one should find n-1 points of t between a and b and then find the corresponding values to plot the figure. Below shows an example of a sin function in the range of 0 and 1 with 1000 increments, as well as the figure. >> t = 0:0.001:1; >> y = sin(2*pi*2*t); >> figure >> plot(t, y) 0 02 04 06 08 Demonstrate a...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • In MATLAB plot the following: The function is periodic, with time period 2T=2, after t=2 the...

    In MATLAB plot the following: The function is periodic, with time period 2T=2, after t=2 the same sinusoidal components repeat in the same way as when 0 st < 2. The function its expanded from one time period 27, in terms of the sinusoidal components. All sinusoidal components have frequencies which are integral multiples of the fundamental frequency. 1 1 = = = 0.5Hz to = fo = cot I am cos(womt) + b, sin(wont) m=1 rad wo = 2nfo...

  •    MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each...

       MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each plot should have its own figure associated with it. In all questions, give the figure a title, and label the acis. Save your matlab script as drill 10.m Do not use the fplot command. 1. Plot the function f(x) = (x + 5)2 for -5 <<<10. Include a plot title, and label both aris. 2. Use the subplot command to make two plots of...

  • 3. Let B = 105 Hz. Let the input be x(t)= sin(10pit) a. Use Matlab plot...

    3. Let B = 105 Hz. Let the input be x(t)= sin(10pit) a. Use Matlab plot the output, y(t). b. What percentage of the total average input power appears at the output of the filter?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT