Question

Write a MATLAB function that outputs number of values in a matrix that’s greater than a...

Write a MATLAB function that outputs number of values in a matrix that’s greater than a compare value. The function must able to take in an arbitrary size matrix.

Name your script/program as “Quiz 2”.

Examples :

Matrix = [1 2 3; 4 5 6]           Compare_Value = 2

Output = 4

Matrix = [1 2 3 1; 4 5 6 8]           Compare_Value = 2

Output = 5

Homework Answers

Answer #1

OUTPUT

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
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 in Matlab that takes as input the number of iterations k, the size...
Write a function in Matlab that takes as input the number of iterations k, the size n, and a sparse matrix A. Have this function run the Power method for k iterations on an initial guess the vector of 1’s and output the dominant eigenvalue and its corresponding eigenvector. Use only basic programming. Write out or print out your function.
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...
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method...
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method (use the form of second-order Runge-Kutta method, Eqs(10.65),(10.66)). For function name and arguments use [x,y]=odeMIDPOINT(ODE,a,b,h,yINI). The input argument ODE is a name for the function that calculates dy/dx. It is a dummy name for the function that is imported into odeMIDPOINT. The arguments a and b define the domain of the solution, h is step size; yINI is initial value. The output arguments, x...
using matlab please present code for the following (ALL PARTS PLEASE AND THANK YOU) 1. No...
using matlab please present code for the following (ALL PARTS PLEASE AND THANK YOU) 1. No Input/No Output Write a function that has no input and no outputs. This function will simply display some text when it is called. (this is my code, are there suggestions for improvements?) function Display() disp('some text') end 2. 1 Input/No Outputs Write a function with one input and no outputs. This function will simply display a variable that is provided as an input argument....
Write a MATLAB function and test bench script code to solve the above simple RL/RC circuits...
Write a MATLAB function and test bench script code to solve the above simple RL/RC circuits by following the instructions noted below. The input signal and impulse response generation should be done in the function. The test bench script should be used only to call the function and for signal plotting purposes. No plotting should be done inside the function itself. Name your function L2_C Instructions: Input voltage ,x(t), can be AC or DC. Consider a variable ‘w1’ which can...
By Using Matlab Matcal (A, B) returns matrix A and B products, while printing the matrix...
By Using Matlab Matcal (A, B) returns matrix A and B products, while printing the matrix computation formula in outmat. txt file as follows. (The sizes of A and B are very variable. In other words, it shall be possible to perform operation for matrix operation of 2 x 2 size, and it shall also be possible to calculate and output for 100 X 100 matrix models. ) >> A = [1 23;4 56 ; 79] >> B = [0...
Write a Matlab R program that plots the ramp response of the values of the voltage...
Write a Matlab R program that plots the ramp response of the values of the voltage across the capacitor for any arbitrary value between 1 and 10,000 Ohms resistor (R), 0.1 to 3 Henry inductor (L), and capacitor (C) values between 0.000001 and 0.1 Farad of a series resistor, inductor, and capacitor (RLC) circuit. Suggestions 1. Determine the transfer functions H(s) of the series RLC circuit where the output is capacitor voltage. 2. Determine the rational functions defined by the...
USING MATLAB Write a MATLAB function that simulates a single roll of a n-sided die. The...
USING MATLAB Write a MATLAB function that simulates a single roll of a n-sided die. The inputsand outputs of the function are: Inputs: •The probabilities for each side, given as a vector p = [p1,p2...pn] Outputs: •The number onthe face of the die after a single roll, i.e.onenumber fromthe setof integers {1, 2 ,....n} Note: The sum p1+p2+.....pn must be equal to 1.0, otherwise the probability values are incorrect. Savethe function as: nsided_die(p) Test the functionwitha 5-sided die,where the probabilities...
Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1...
Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1 on the super- and sub-diagonal. Then replace the (1,1) element of A with a 1. (Make your commands capable of handling an arbitary sized NxN matrix by first defining N=5, then using the variable N as the size in each of the commands.)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT