Question

Write a function called odd_rms that returns orms, which is the square root of the mean...

Write a function called odd_rms that returns orms, which is the square root of the mean of the squares of the first nn positive odd integers, where nn is a positive integer and is the only input argument. For example, if nn is 3, your function needs to compute and return the square root of the average of the numbers 1, 9, and 25. You may use built-in functions including, for example, sum and sqrt, except for the built-in function rms, which is not allowed.

Homework Answers

Answer #1

clc
clear all
close all
nn=input('Enter number of odd values to be considered: ');
orms=odd_rms(nn);
fprintf('The RMs value of first %d odd square numbers is:',nn)
disp(orms)

-------------------------------------

function orms=odd_rms(nn)
temp=0;
for i=1:2:(2*nn-1)
temp=temp+i^2;
end
orms=sqrt(temp/nn);

Output:

Enter number of odd values to be considered: 5
The RMs value of first 5 odd square numbers is: 5.7446

Enter number of odd values to be considered: 3

The RMs value of first 3 odd square numbers is: 3.4157

Know the answer?
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
Similar Questions
Write a function called odd_rms that returns orms, which is the square root of the mean...
Write a function called odd_rms that returns orms, which is the square root of the mean of the squares of the first nn positive odd integers, where nn is a positive integer and is the only input argument. For example, if nn is 3, your function needs to compute and return the square root of the average of the numbers 1, 9, and 25. You may use built-in functions including, for example, sum and sqrt, except for the built-in function...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except for 1s on the reverse diagonal from top right to bottom left. The reverse diagonal of an n-by-n matrix consists of the elements at the following indexes: (1, n), (2, n-1), (3, n-2), … (n, 1). The function takes one positive integer input argument named n, which is the size of the matrix, and returns the matrix itself as an output argument. Note that...
Using C++ Write a template function that accepts an integer parameter and returns its integer square...
Using C++ Write a template function that accepts an integer parameter and returns its integer square root. The function should return -1, if the argument passed is not integer. Demonstrate the function with a suitable driver program .
Python Question: Write a function which returns the sum of squares of the integers 1 to...
Python Question: Write a function which returns the sum of squares of the integers 1 to n. For example, the sum of the squares from 1 to 4 is 1 + 4 + 9 + 16, or 30. You may choose what should be returned if n == 0 You may not use the built-in Python sum function. The Solution Must be recursive >>> sum_of_squares(1) 1 >>> sum_of_squares(4) 30 >>> sum_of_squares(8) # 64 + 49 + 36 + ... +...
Write a function that takes two integer inputs and returns the sum of all even numbers...
Write a function that takes two integer inputs and returns the sum of all even numbers between these inputs, and another function that takes two integer inputs and returns the sum of odd numbers between these inputs .In main function, the program will asks the user to enter two integer numbers and then passes them to these two functions and display the result of each of them.         [0.5 mark] (BY USING C PROGRAM)
: The Root Mean Square of a discrete-time signal is given by We can easily calculate...
: The Root Mean Square of a discrete-time signal is given by We can easily calculate the RMS of signals in MATLAB using a combination of the sum, sqrt, and ^ commands. N represents the number of samples of the signal. Please note that the command .^ applied to a vector squares each element of the vector. Write a script to calculate the RMS of the discrete-time signal x, defined as follows: n = a vector of number between -23...
Write a function called sum_half that takes as input a square matrix A and computes the...
Write a function called sum_half that takes as input a square matrix A and computes the sum of its elements that are in the upper right triangular part of A, that is, elements in the diagonal and elements that are to the right of it. For example, if the input is [1 2 3; 4 5 6; 7 8 9], then the function would return 26. (That is, 1+2+3+5+6+9) Note, the function triu is not allowed. Please write as you...
Write a PYTHON function called myMax which accepts a LIST of numbers and returns the maximum...
Write a PYTHON function called myMax which accepts a LIST of numbers and returns the maximum number in the list. Do NOT use Python’s built-in function max. Example: result = myMax([-999000, -1000000, -2000000]); print(result) #output is -999000 Example: result = myMax([1000000, 1000001, 1000002]); print(result) #output is 1000002
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its...
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = matrix_problem([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. The function should work...
Write a function find square root(x) that takes as input a number x and as output...
Write a function find square root(x) that takes as input a number x and as output returns the square root of x. Your results should converge to at least 6 decimal places. matlab question
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • You are the manager of a local coffee shop. There are two types of customers in...
    asked 12 minutes ago
  • Count the number of different functions with the given domain, target and additional properties. (a) f:...
    asked 13 minutes ago
  • This is for retail store perspective. The control types could include feedforward controls, concurrent controls and...
    asked 21 minutes ago
  • Q-1 Every hour a quality control inspector measures the outside diameter of four parts. The results...
    asked 32 minutes ago
  • Precise Equipment Manufacturing (PEM) is an engineering company that specialises in motor components. PEM have asked...
    asked 32 minutes ago
  • What adaptations does a snake have that allows it to be successful in its natural habitat?...
    asked 42 minutes ago
  • What causes different sizes of silver nanoparticles to appear as different colors in solution?
    asked 53 minutes ago
  • 1) Consider two products A and B that have identical cost, retail price and demand parameters...
    asked 56 minutes ago
  • University Electronics has provided the following information for last year: Sales revenue $ 4,030,000 Store rent...
    asked 1 hour ago
  • A consulting firm has two departments, Corporate and Government. Computer support is common to both departments....
    asked 1 hour ago
  • Nine industrial workers were tested for gripping strength and the mea- surements were 128.3, 106.5, 93.9,...
    asked 1 hour ago
  • a. Create a spreadsheet describing Amazon’s output and pricing choices with respect to the Kindle e-reader....
    asked 1 hour ago