Question

Matlab Problem: please use matlab format, thank you in advance!!

Problem 6 (1 point. Instructors Initials This is Problem 5.20 in the text, with the following corrections and additions: 1) There is an error in the formula for f(x). The correct formula is saies seroatmation dfs ea ee witn m 1,3. 1 2??? -sin 4 /A f(x) = Write a program that accepts as user input the number of terms in the sum. For example, if the user requests 3 terms in the sum, the program should compute the sum for n- 1, 3, and 5. The program should then plot the approximate waveform, from x0 to 2L. This should show 2 cycles of the square wave as displayed in the figure. Let L- 1 for this problem. 2) 0.5 Demonstrate operation to the instructor, and print a copy of the program to attach to the lab.

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

Matlab code for square wave approximation

=====================

L=1; % defining L
x=0:0.001:2*L; % generating vector x
n=input('number of terms: '); % accepting no of terms as user input
f=zeros(1,length(x)); % initializing vector to store the approximation
for i=1:length(x) % for all values of x=0,0.001,...2
sum=0; % initializing sum to 0
for j=1:2:2*n-1 % for n =1,3,5..
sum=sum+(1/j)*sin((2*j*pi*x(i))/L); % evaluating the summation part
end
f(i)=(4/pi)*sum; % multiplying summation with the constant
end
plot(x,f) % plotting the approximation of square wave
title('fourier series approximation of square wave')

=====================

Output

G: Program Files* MATLAB R2017a» Editor - GProgram Files MATLABR2017asquareFourAppx.nm X Command Window calcAnalyze.m Х gibbs

Add a comment
Know the answer?
Add Answer to:
Matlab Problem: please use matlab format, thank you in advance!! Problem 6 (1 point. Instructor's Initials...
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
  • MatLab Problem: Please use matlab format and follow instruction on the problem, thank you in advance!...

    MatLab Problem: Please use matlab format and follow instruction on the problem, thank you in advance! Problem 2 (1 point. Instructor's Initials) Determine all values of x that satisfy the following system of non-linear equations: y = sin(x) Graph the two functions, and hand-write the solution (or solutions, if more than one) on the graph. Include your name in the title of the graph.

  • Use MATLAB to solve this problem. Thank you. Upload the assignment to CANVAS, it should include...

    Use MATLAB to solve this problem. Thank you. Upload the assignment to CANVAS, it should include two things: the PDF and the zipped folder. Late assignments are not accepted. For the questions below, do not create the arrays or matrices by hand. Instead, use built-in MATLAB functions and shorthand notations. Otherwise, no points will be given. 1) Create a function called my product that computes the multiplication of the numbers in any vector using a while loop. The function should...

  • MATLAB You Cannot Use guide, You must create a GUI using code only Problem 1 (100...

    MATLAB You Cannot Use guide, You must create a GUI using code only Problem 1 (100 pts) This week you will repeat the second problem from Week 8 (the problem is restated below for your convenience) but you will add a GUI (without using guide) for the user to control the execution of the program. Your program should do the following: Create a figure that contains a plotting area and user interface controls Allow the user to input the initial...

  • Complete Textbook problem 9.18 using Matlab (you can use a 10^-6 as your tolerance) a. Format...

    Complete Textbook problem 9.18 using Matlab (you can use a 10^-6 as your tolerance) a. Format your function such that [x] = lastname_firstname_GaussPivot(A, b). Submit your original M-file. Develop, debug, and test a program in either a high-level language or macro language of your choice to solve a system of equations with Gauss elimination with partial pivoting. Base the program on the pseudocode from Fig. 9.6. Test the program using the following system (which has an answer of x_1 =...

  • Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial...

    Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial lauw angle of 0x. The impact point of the projectile Pa is a point B in a valley with an ordinate, yon, located below the clevation of point A. The launch from point A is instantaneously detected at point B, and a counter projectile P launched simultaneously...

  • Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b):...

    Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b): Write a program that gives remainder without using modulus operator and loops. The first number entered will be dividend and second number entered will be divisor. Sample input: 15 6 Sample output: Remainder is 3 In a right triangle, the square of the length of one side is equal to the sum of the squares of the length of the other two sides. Write...

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