Question

write a code please Problem 1 Write MATLAB programs to find the following sums with for loops. (a) 12 + 22 + 32 + ... ... ... + 10002. (b) 1 –}+*

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

PROBLEM 1

First series is pretty straightforward to implement

For the second series

First term is \frac{-1^{n}}{2n+1} = 1 for n = 0

Second term is \frac{-1^{n}}{2n+1} = -1/3 for n = 1

Third term is \frac{-1^{n}}{2n+1} = 1/5 for n = 2

and so on

for the last term will be for n =501

MATLAB script for the series

clc;
close all;

%%% The first series
sum1 = 0;
for i = 1:10
sum1 = i^2 + sum1;
end
%%% Display the sum in command window
fprintf('The sum of 1st series is %d \n',sum1);

%%% The second series
sum2 = 0;
for n = 0:501
sum2 = ((-1)^n)/(2*n +1) + sum2;
end
%%% Display the sum in command window
fprintf('The sum of 2nd series is %f \n',sum2);

Command line output

1588075883754_image.png

PROBLEM 2

For the vector plot, define x between -4 and 4

Vector (function fx) is defined using dot operators as shown in the script below

The plot for -2.7<= x <= 2.7 is obtained by using MATLAB xlim function

MATLAB script

x = linspace(-4,4);
%%% Creates vector x with 100 equidistant points between -4 and 4
fx = 0.6.*x.^5 - 5.*x.^3 + 9.*x +2;
%%% Defines vector fx using dot operators

figure(1)
%%% Plot fx for x between -4 and 4
plot(x,fx);
grid on

figure(2)
%%% Plot fx for x between -2.7 and 2.7, limits set by xlim function
plot(x,fx);
hold on
grid on
xlim([-2.7 2.7]);

Plots

Add a comment
Know the answer?
Add Answer to:
write a code please Problem 1 Write MATLAB programs to find the following sums with for...
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
  • Don't use fplot command. Matlab code. Write out code please, don't make it a screenshot. 2....

    Don't use fplot command. Matlab code. Write out code please, don't make it a screenshot. 2. Use the subplot command to make two plots of the function f(x) = (x + 1)(x - 2)(2x – 0.25) - et one graph for 0 < x <3 and the other for 3 < x < 6. Use a logarithmic scale for the y-axis. Include a plot title (for each subplot), and label both aris(for each subplot).

  • Q: please solve using matlab code withe comment 1.      Write the Matlab code to generate: x...

    Q: please solve using matlab code withe comment 1.      Write the Matlab code to generate: x = cos(w1*t) + cos(w2*t); where, w1=7; w2=23; t = [0:0.005:2] 2.   Plot the signal using sub plot a.   in time domain b.   in frequency domain 3)   Sample the signal under different sampling conditions: a.      Ts<1/2fm b.      Ts=1/2fm c.       Ts>1/2fm 4).      Multiple plot: the signal sampled under sampling condition and the signal x a.      in time domain b.      in frequency domain c.       Label and Title...

  • Can someone help me figure out how to write code on Matlab for either of these...

    Can someone help me figure out how to write code on Matlab for either of these two questions? My biggest problem is working with the large factorials which Matlab can't seem to handle 1. Write a code to calculate nas a function of ga, when NA l300, 600, 3000, 6000, NB (200, 400, 2000, 4000), and g 100, plot them and try to find some tendency when N increases (hint: 4 plots). 2. Write a code to calculate the probability...

  • IN MATLAB RECURSIVE FUNCTION 1. Sum of Factorials. The Recursive Function: A series that sums up...

    IN MATLAB RECURSIVE FUNCTION 1. Sum of Factorials. The Recursive Function: A series that sums up the factorial of the natural numbers from 1 to N can be expressed as The recursive algorithm: N-1 N-2 N-3 Write independent matlab code to solve the above problem with the following methods: 1. 2. 3. A monolithic program (with no functions) A standard (non-recursive) user defined function (an a program to call it) A recursive function (an a program to call it) Test...

  • Please show me the MATLAB CODE for this problem Thank you Write programs that determine solutions...

    Please show me the MATLAB CODE for this problem Thank you Write programs that determine solutions for polynomials (quadratics, et al) a) Create a program that presumes the user-entered values (a,b,c) represent a valid quadratic equation and your initial program simply solves the equation and reports the real or imaginary roots. b) Create a flowchart that describes all possible combinations of user entered data, e.g. perhaps a user enters (1, 0, -4) as (a, b, c) which is of course...

  • Please use matlab, post the code, and dont just write the code by hand. Thank you!...

    Please use matlab, post the code, and dont just write the code by hand. Thank you! 4 [3 points] Use the function f(x on the interval [5, 5] and the 11 points below to find a N-10 Lagrange polynomial, using MATLAB. You will need to write code for and plot the polynomial as a function of x, but you do not have to write the polynomials down by hand 5 0 2 3 4 5 f(x) | 0.0399 | 00623...

  • please sketch the polar plot of the frequency response.. (briefly please work in matlab) Problem-1 (100...

    please sketch the polar plot of the frequency response.. (briefly please work in matlab) Problem-1 (100 pts) Sketch the polar plot of the frequency response for the following loop transfer functions and analyze the stability of these systems based on the polar plots. (Hint: You can write a Matlab code to plot the response of these systems in polar coordinates and include your code in your report. Plots obtained by using the "nyquist0" function of Matlab will get a zero...

  • Problem 2: A periodic signalxit) is shown below A =10, T-4 sec. -T Write a MATLAB script to plot ...

    Problem 2: A periodic signalxit) is shown below A =10, T-4 sec. -T Write a MATLAB script to plot the signal, using enough points to get a smooth curve. Compute the Fourier series coefficients for the signal (if you can find them in the text, that is ok). Plot the single-sided or double-sided spectra for each signal. Include enough frequencies in the plots to adequately represent the frequency content of the signals. Plot partial sums of the Fourier series for...

  • The matlab code for the following problem is appreciated!! QUESTION 3 Write a function fnfr_plot that...

    The matlab code for the following problem is appreciated!! QUESTION 3 Write a function fnfr_plot that will receive two function handles from elementary math functions which accept a vector to first sort in ascending order then calculate. The script will display the results in two separate Figure Windows with the function names in the title. Submit: fnfr_plot.m Browse My Computer Attach File QUESTION 4 Generate 1x100 random vector, x in the range of 0<x<100 by using rand. Input 2 elementary...

  • The following snippet of code will store the r and y coordinates of 10 points in 4 different row vectors and then plots 5 vectors between certain pairs of those points Show/hide Matlab code snippet 1...

    The following snippet of code will store the r and y coordinates of 10 points in 4 different row vectors and then plots 5 vectors between certain pairs of those points Show/hide Matlab code snippet 1 A-1:5; B A +1/sqrt (2); C = ones(1,5) D C +1/sqrt (2); plot([A; B], [C; D]) axis equal Which of the following statements about the plot produced by the above snippet of Matlab code are correct. The vectors plotted are the vectors from the...

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