(a) Write a well-commented MATLAB function program mysolvecheck with input a number n that makes a random n x n matrix A and a random vector b, solves the linear system Ax = b, calculates the scalar residual r= ||Ax - b||, and outputs that number as r. (b) Write a well-commented MATLAB script program that calls nysolvecheck 10 times each for n = 5, 10, 20, 40, 80, and 160, then records and averages the results and makes a log-log plot of the average r vs. n. Once your program is running correctly, increase the maximum n (by factors of 2) until the program stops running within 5 minutes. Turn in the plot and the two programs. (Do not print any large random matrices.)
Q: The exponential function e* can be approximated using a Taylor/Maclaurin series 00 e* %3D п! n=0 a)…
A: Since there are two questions, according to the guidelines I can solve only first question.…
Q: 1. Create a vector of the even whole numbers between 31 and 75.
A: MATLAB is developed by MathWorks and is a multi-paradigm programming language.
Q: (M.5) f(x, y) = 3x² – 2xy+ y2 – 4x x € [-7,5], y e [-7,7]
A: Answer: I have done code and also I have attached code and code screenshot as well as output
Q: Write a Matlab code to perform the following: a) Ask the user to enter a number, and place it in the…
A: The Answer to the following question:-
Q: Write a Matlab function named reflect_polynomial that will: [a] accept a univariate polynomial…
A: The objective is to write MATLAB code for the given data.
Q: Question 11 For all a and b in the domain of a function f, the function is injective iff…
A: Injective is basically a one on one function. No two elements can map to the same domain. So if a=b…
Q: IN MATLAB write a function named 'growrate.m' that takes three inputs: 1) initial population size…
A: Here below we make simple i=user defined function to fulfill the given requirement:…
Q: Define a function S: Z+ → Z+ as follows. For each positive integer n, S(n) = the sum of the…
A: Given function: S: Z+ →Z+ For each positive integer n, S(n) = The sum of the positive divisor of n.
Q: Problem 1. [Category: Asymptotic notations] In this question, you are asked to compare pairs of…
A: Please upvote. I am providing you the correct answer below. Please please please.
Q: Write Matlab code to find the roots of the following equation (Using graphical method): f(x) = sin…
A: clcclear alla_max = 2;a=0:0.01:x_max;b= sin(10*a)+cos(3*a);plot(a,b);hold onezplot('0');grid…
Q: Define a function CalcPyramidVolume() with double data type parameters baseLength, baseWidth, and…
A: Here we need to have two function area() and volume() and the function volume() calls area()…
Q: Write a MATLAB program to define a vector v that takes the values [3 4 5 6 7] and then uses this…
A: Code: v=3:1:7 % av1=(v-1).^(5-v) % bv2=(v.*2)./(v+3) % cv3=-(v-1)…
Q: Define a function S : Z+ → Z+ as follows. For each positive integer n, S(n) = the sum of the…
A: Here we have given function definition and solved s(n)
Q: Define functions f, g, h, all of which have R as their domain and R as their target. f(x) = 3x + 1…
A: Given f(x) = 3x+1 g(x) = x2 h(x) = 2x
Q: The MATLAB function roots is used in the following statement: p= roots(x) Identify the correct…
A: Ans: x is a vector containing the coefficients of the polynomial. p is a vector containing…
Q: You are explaining the problem of searching for a move in chess to your friend. Your friend notices…
A: The strategy wouldn't work since the differentiation is not guaranteed to give a maxima always,…
Q: A MATLAB code to compute sum of cube-of-each-element of a vector v is given by: s=0; v=[10 5 8]; for…
A: -> Given code has bugs because we can't do v(i^2) in MATLAB and sum is not s^1/3. a) Correct code…
Q: Given the Matlab function function s = fun(a, b, c) s = zeros (1,3);% s has 1 row, 3 cols, and is…
A: Explanation of function execution: “s=zeros(1,3)” returns an array of zeros, where size vector “1,…
Q: In matlab We have two vectors containing the weight and height of a group of people. The vector H…
A: As per our guidelines, we are supposed to answer only 1st three parts. Kindly repost the remaining…
Q: Consider the continuous function x2 + 2x + 3 if æ < 0 if 0<I< 2 2² + 4x – 7 if 2 < z. f(r) = {r+3…
A: Code: tempFn <- function(xVec){ f = integer(length(xVec)) for (i in seq(1, length(xVec)))…
Q: B/ Write a matlab code to find sum all elements of a vector, if the vector is the following: M=[5,…
A: Input : Create the vectors M. Output : Use the control statement to find the sum of all elements…
Q: Create a MATLAB function that selects a random element from a list of values in a vector. Using the…
A: % save this file in select_random_option.m function [value] = select_random_option(arr) % get one…
Q: Write expression as sum of Minterms for Any One Neutral function F over 04 variables A, B, C, and…
A: Answer is given below-
Q: Create a MATLAB code that solves roots of non-linear equations using False-Position Method. The code…
A: BELOW IS THE ANSWER- %ingridients f= input('enter your function: '); a= input('enter left side of…
Q: (A) Write a user-defined MATLAB Function for the following math function: Z(x, y) = e* cosy + sin(x2…
A: As per requirement question solved using MATLAB code:
Q: NEWTON-RAPHSON METHOD EXAMPLE 1: Find the root of the function ?(?) = cos (?) using NRM having…
A: The given code throws error. Because while printing the function cos(x) is taken as string but while…
Q: Write a function iterate that takes a numerical vector v and returns the iteration/index at which…
A: Answer :
Q: (A) Write a user-defined MATLAB Function for the following math function: Z(x, y) = e* cosy +…
A: a)Matlab Script: Define function and save it as file name Z. function…
Q: 1-Write the matrix in the MatLab.: H=[1:3;4:7] And find the results of the following: a- G=2H?, b-…
A: Please refer below code and output : Language used is Matlab: 1): H=[1 3 ; 4 7]; a=2*H *H;
Q: (a) Given an n x 2 matrix X, we can move the shape represented by the coordinates in X by a in the…
A: Below find the solution !! (a) shift <- function(X,a,b){ X[,1] <- X[,1] + a X[,2] <- X[,2]…
Q: Write a user-defined Matlab function that receives two vectors as input argument. If the two vector…
A: Please refer below code and output: for testing purpose i have used two vectors and passed: clc;…
Q: Use a matlab function to convert cartesian to polar coordinates
A: Matlab command(s) and response(s) (copy/paste or type in): >> [TH,R]= cart2pol(-3,4)
Q: In Matlab We are going to calculate the average to these datapoints (the measurements is a vector…
A: Here we write a matlab code: ================================== below we make function to find…
Q: Write a user-defined MATLAB function for the following math function: y(x) = 0.6xe-0.47* +…
A: Actually MATLAB is a programming platform designed specially for engineers.
Q: Operations on Polynomials For the following polynomials 1. Convert the symbolic function f(x) = 3x –…
A: As per our guidelines, we are supposed to answer only 1st three parts. Kindly repost the remaining…
Q: (A) Write a user-defined MATLAB Function for the following math function: Z(x, y) = e* cosy + sin(x?…
A: the answer is an given below :
Q: Define a MATLAB function named printRandomColumn() that would accept a matrix of any dimension as…
A: % sample matrix for testing data_sample = [20,30,40 ; 1,3,5] % Function call…
Q: ations given below are the mathematical models of the three mixed tanks that are connected in…
A: I have written the MATLAB Code below:
Q: 1. State the definition of a function and a composite function. Let f and g be functions defined as…
A: Function : an expression, rule, or law that defines a relationship between one variable (the…
Q: Write a MATLAB function called Gauss which receives as its two input arguments a square matrix A and…
A: Solution: Given,
Q: Consider the following function for 2-vector x = (x,x)“. Bold letter indicates vector f(x) = f(x…
A: We need to create the two vectors x1 ,x2 ,then compute the f(x) , f_hat(x) ,plot it and compute the…
Q: B) Write a MATLAB program to solve TWO of the following: (1) Let x=[2 6; 1 8], y=[5 -0.3; -0.1 0.2],…
A: Consider the given (a) x=[2 6;1 8] y=[ 5 -0.3;-0.1 0.2]
Q: The equations given below are the mathematical models of the three mixed tanks that are connected in…
A: What is Matlab: MATLAB is a proprietary multi-paradigm programming language and numeric computing…
Q: I need a function user a by using a matlab multiply matrix by vector a point wise
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: (Simple function plotting) Often, we wish to plot a given function f which is alrcady coded in…
A: Code: plot_func(@(x) x.^2+1,-3,3,6)function y=plot_func(f,a,b,n) x=a:(b-a)/n:b y=f(x)…
Q: 4. Write a Julia function called resistance that returns the resistance distance r, given the…
A: Write a julia function called resistance that returns the resistance distance rij given Cholesky…
Q: A robot moves in a 2D lattice. The robot can only move north (N), south (S), east (E), and west (W)…
A:
Q: Write a python function, NRS(fv, Jf, xo, tol), that takes in a vector-valued, multi-variable,…
A: Answer: I have written code in python.
matlab
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Implement the following function, without using any data structure or #include <bits/stdc++.h> /* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’. e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’. Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars @pre: list1, list2 have been initialized @post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameMultiSet (vector<char> list1, vector<char> list2) THIS IS NOT THE CORRECT SOLUTION / include headers #include <bits/stdc++.h> // deinfe the namespace using namespace std; // function fo rchecking same bool…C++ 13.9.2 Pass by reference Define a function ScaleGrade() that takes two parameters: points: an integer, passed by value, for the student's score. grade: a char, passed by reference, for the student's letter grade. ScaleGrade() changes grade to A if the points are greater than or equal to 88 and less than or equal to 100, and grade is not A. Otherwise, grade is not changed. The function returns true if grade has changed, and returns false otherwise. Ex: If the input is 88 B, then the output is: Grade is A after curving. Using the following code #include <iostream>using namespace std; // insert code here int main() { int studentPoints; char studentGrade; bool isChanged; cin >> studentPoints; cin >> studentGrade; isChanged = ScaleGrade(studentPoints, studentGrade); if (isChanged) { cout << "Grade is " << studentGrade << " after curving." << endl; } else { cout << "Grade " << studentGrade…13. Implement function triangleArea(a,b,c) that takes as input the lengths of the 3 sides of a triangle and returns the area of the triangle. By Heron's formula, the area of atriangle with side lengths a, b, and c is √ s ( s−a )( s−b)( s−c ) , where s=(a+b+ c )/ 2 .>>> triangleArea(2,2,2)1.7320508075688772
- 21.2 Project 1 (Checkpoint B): DNA Write the full C++ code for this Implement the following functions: /** * Reads from standard input a list of Short Tandem Repeat (STRs) * and their known counts for several individuals * * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @param nameIndividuals the names of individuals (eg. Alice, Bob, Charlie) * @param STRcounts the count of the longest consecutive occurrences of each STR in the DNA sequence for each individual * @pre nameSTRs, nameIndividuals, and nameSTRs are empty * @post nameSTRs, nameIndividuals and STRcounts are populated with data read from stdin **/ void readData(vector<string>& nameSTRs, vector<string>& nameIndividuals, vector<vector<int>>& STRcounts) For example, consider the input: 3 AGAT AATG TATC Alice 5 2 8 Bob 3 7 4 Charlie 6 1 5 In the first line, the number of STRs followed by the names of those STRs, which will be populated into the vector nameSTRs. The remaining lines contain…Problem Statement: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, wherelength(TAM) is the number of letters of TAM. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used…Problem Statement: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only…
- Problem Statement: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only…Please written by computer source Question 1: Suppose we wish to write a procedure that computes the inner product of two vectors u and v. An abstract version of the function has a CPE of 14–18 with x86- 64 for different types of integer and floating-point data. By doing the same sort of transformations we did to transform the abstract program combine1 into the more efficient combine4, we get the following code: Our measurements show that this function has CPEs of 1.50 for integer data and 3.00 for floating-point data. For data type double, the x86-64 assembly code for the inner loop is as follows: Assume that the functional units have the characteristics listed in Figure 5.12. **See last page for figures A. Diagram how this instruction sequence would be decoded into operations and show how the data dependencies between them would create a critical path of operations, in the style of textbook Figures 5.13 and 5.14. vmovsd vmovsd vmulsd vaddsd | | | |…12. Consider the recursive function int gcd( int a, int b) int gcd( int a, int b){ if (b > a) return gcd(b,a); if ( b == 0 ) return a; return gcd( b, a% b); } How many invocation (calls) of the gcd() function will be made by the call gcd(72, 30)?
- Exercise 1: Memory Allocation in C a) Write a C program which dynamically allocates memory to define an integer 5 x 5 matrix initialized to zero by using the calloc function. Do not forget to free the memory in the end of your program. b) What happens if you attempt to print your matrix before and after freeing memory?Implement the following function, without using any data structure. /* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’. e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’. Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars @pre: list1, list2 have been initialized @post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameMultiSet (vector<char> list1, vector<char> list2)(a) Write a function matrix_multiply(mat1, mat2) that takes two matrices and returns the result of the matrix multiplication between mat1 and mat2. If the two matrices are not compatible with multiplication, then None should be returned. (b) Write a function print_sums(list1, list2) that takes two equal-length lists of numbers and prints all the sums of the corresponding elements. Thus the first line is the sum of the first element of list1 and the first element of list2, the second line is the sum of the second elements, and so on.