Question

Is there any way to take this input: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% n=input('How many values will you been inputing?...

Is there any way to take this input:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

n=input('How many values will you been inputing? --> '); %

m=zeros(1:n); %

for m=1:n %

x(m)=input('Please input a value for x! --> '); %

end %

y=rms(x); %

z=harmmean(x); %

fprintf('The Root mean square is %f!\n',y); %

fprintf('The Harmonic Mean is %f!\n',z); %

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

and make it output:

Enter number of values: 5

Enter value 1: 11

The RMS average is 11.0000

The Harmonic Mean is 11.0000

Enter value 2: 22

The RMS average is 17.3925

The Harmonic Mean is 14.6667

Enter value 3: 33

The RMS average is 23.7627

The Harmonic Mean is 18.0000

Enter value 4: 44

The RMS average is 30.1247

The Harmonic Mean is 21.1200

Enter value 5: 55

The RMS average is 36.4829

The Harmonic Mean is 24.0876

While creating a UDF function and calling it into your code?

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

Solution: The nodified code is shown below: %set value of n n5; %Define x= [ ] ; array Define a vector yy yy = [11 22 33 44 5

Sample Output: Enter value 1 11! The Root mean square is 11.000000! The Harmonic Mean is 11.000000! Enter value 2 22! The Roo

Code:

%Set value of n

n = 5;

%Define array

x=[];                                                                                %

%Define a vector yy

yy = [11 22 33 44 55];

%Loop until end

for i = 1:5

     %Add value to end of vector

    x(end+1) = yy(i);

    

     %Display value

     fprintf('Enter value %d %d!\n',i, yy(i));

    

     %Compute rms value

     y=rms(x);

   

     %Compute mean

     z=harmmean(x);

                 

     %Display message

     fprintf('The Root mean square is %f!\n',y);   

     %Display message

     fprintf('The Harmonic Mean is %f!\n',z);

    

%End

end

Add a comment
Know the answer?
Add Answer to:
Is there any way to take this input: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% n=input('How many values will you been inputing?...
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
  • The first two parts should be solved by Matlab. This is from an intro to Numerical...

    The first two parts should be solved by Matlab. This is from an intro to Numerical Analysis Class and I have provided the Alog 3.2 in below. Please write the whole codes for me. Alog3.2 % NEWTONS INTERPOLATORY DIVIDED-DIFFERENCE FORMULA ALGORITHM 3.2 % To obtain the divided-difference coefficients of the % interpolatory polynomial P on the (n+1) distinct numbers x(0), % x(1), ..., x(n) for the function f: % INPUT: numbers x(0), x(1), ..., x(n); values f(x(0)), f(x(1)), % ...,...

  • Lastname, Firstname MECH 1314 Homework #12-Bisection Due: 4/22/2019 Instructions: Submit your scr...

    Lastname, Firstname MECH 1314 Homework #12-Bisection Due: 4/22/2019 Instructions: Submit your script in a file named hwk12.m to the dropbox before 11:59 pm on the due date 20 pts The "root" of an equation, y f(x), is a value of x for which y has a value of zero and it is often "the answer" for a practical engineering problem. For example, ion Algebra you learned the Quadratic Equation, an equation that allows you to compute the value of each...

  • 2. The following causal system is excited by white noise (x[n)=w(n)) of zero mean and unit...

    2. The following causal system is excited by white noise (x[n)=w(n)) of zero mean and unit variance. The output is y(n). q(n)-x(n) 0.8 q(n-1) y(n) 0.2 q(n) a) Determine the autocorrelation of the output y(n) in closed form for all m. Give numerical values for ry(0), ryy(1), ryy(2) b) Find the variance of y(n). Give a numerical value and show all your work. c) Find the poles and zeros of the power spectral density (PSD) of y(n) and sketch them...

  • How do I get my output to print "What class of car do you want" after every loop? Here is my outp...

    How do I get my output to print "What class of car do you want" after every loop? Here is my output, it gets stuck on asking and calculating the cost of the specific class of car i entered previously. clear cic: cars-input ('How many cars do you want to rentln run input ('Would you like to run the program Y or N','S) while run'Y carclass-input ('What class of car do you want B, C, or DIn', 'S while carclassB...

  • The following causal system is excited by white noise (x(n)=w(n)) of zero mean and unit variance....

    The following causal system is excited by white noise (x(n)=w(n)) of zero mean and unit variance. The output is y(n). q(n)=x(n) - 0.8 q(n-1) y(n)=0.2 q(n) a) Determine the autocorrelation of the output y(n) in closed form for all m. Give numerical values for ryy(0), ryy(1), ryy(2). b) Find the variance of y(n). Give a numerical value and show all your work. c) Find the poles and zeros of the power spectral density (PSD) of y(n) and sketch them carefully...

  • help with C++ please Substituting these formulas, the Newton-Raphson update rule for computing the n' root...

    help with C++ please Substituting these formulas, the Newton-Raphson update rule for computing the n' root of any value K is: 2+1 = - na"-T Write a program that includes a user-defined function named root that will calculate and return the nth root of any value using the Newton-Raphson method described above: double rootN(double x, int n); The function takes two arguments: a (type double) value > 0 and an integer root > 1. This function should work exactly as...

  • i need help with 2b please is a set of input values, Y- 2. In this question, we reuse the notation of lecture 37: X-{xi, ,x , m-1) is a set of hash values, and H is an [X → Y)-valued random variab...

    i need help with 2b please is a set of input values, Y- 2. In this question, we reuse the notation of lecture 37: X-{xi, ,x , m-1) is a set of hash values, and H is an [X → Y)-valued random variable {0.1, In lecture, we showed that for any hash value y e Y, the expected number of input values that hash to y is k/m, where k XI and m Yl. However, in determining the time it...

  • Java programming 1. Write a program that reads an unspecified number of integers, determines how many...

    Java programming 1. Write a program that reads an unspecified number of integers, determines how many positive and negative value have been read, and computes the total and average of the input values (not counting zeros. Your program ends with the input 0. Display the average as a floating point number Here are sample runs: (red indicates a user input) Enter an integer, the input ends if it is 0: 1 2 -1 3 0 The number of positives is...

  • 5) An N-point moving-average (running-average) system has the following input-output relation shi...

    5) An N-point moving-average (running-average) system has the following input-output relation ship: N-1 a) Is the N-point moving-average system causal? b) Obtain the expression for the impulse response h[n] and sketch hin. c) Given the input sequence [n] below with 100 elements where the values of the index n change between 0 and 99: r-[21 22 22 21 18 19 21 20 19 23 23 22 23 25 27 30 31.5 32 33 32 28 29 28 29 30 32...

  • A) Calculate the mean values <x^2> and <p^2x> for stationery state n. B) Calculate the rms...

    A) Calculate the mean values <x^2> and <p^2x> for stationery state n. B) Calculate the rms deviations sigma(x) and sigma(px) for stationery state n. Check that the Heisenberg uncertainty principle is satisfied. 1. Consider a particle of mass m in an infinite square well with potential energy 0 for 0 saSa otherwise. V (z) = For simplicity, we may take the 'universe' here to be the region of 0 sas a, which is where the wave function is nontrivial. Consequently,...

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