Matlab function myfunc.m for the problem
function res = myfunc(m,v)
% Input
% m: a scalar
% v: a colum vector of size 2x1
% Output
% res: a scalar
h = 1/(m-1); % Computing the value of h
i = 1:m; % crreating i vector varies from 1 to m
x = (i-1)*h; % Calculating x vector
X = [ones(m,1),x']; % Create X using x
Y = 0.1*sin(pi*x'); % Create Y using x
% Now compute the res
res = ((Y')*Y)-(2*((v')*((X')*Y)))+((v')*(((X')*X)*v));
end
Script to call the function to compute res
clc; clear; % Clearing the command window and workspace
m = 20; % setting the value of m as 20
v = [1;1]; % seting the value of v
res = myfunc(m,v); % calling the function to calculate res
% printing the result
fprintf('For m = %d and v = [%d; %d], the res =
%0.4f.',m,v,res);
Screen Print of the code

![1 2 - 3 clc; clear; % Clearing the command window and workspace m = 20; % setting the value of m as 20 V = [1,1]; % seting th](http://img.homeworklib.com/questions/246aee30-48c9-11eb-ab64-a35195efb97c.png?x-oss-process=image/resize,w_560)
OUTPUT of the code
![COMMAND WINDOW For m = 20 and v = [1; 1], the res = 43.3166.](http://img.homeworklib.com/questions/24cf2610-48c9-11eb-baf0-bfa19bfc588c.png?x-oss-process=image/resize,w_560)
2. (a) An object thrown vertically with a speed vo reaches a height h at time t, where: he vot tgt Write a MATLAB program with a user defined function that computes the time required to reach a specified height h, for a given value of vo. The function's input should be h, Vo, and g. Test your function for the case where h 100 m, Vo-50 m/s and g9,81 m/s2 by free hand. Write the MATLAB command how you...
(Matlab) Suppose we have a function “hw5f.m” that takes as input
x and outputs the value for a function f(x). Write a Matlab program
that inputs: • interval [a, b]; • m, the number of data points with
evenly spaced nodes from x1 = a to xm = b, and values from f(x); •
location z satisfying x2 < z < xm−1, where h = (b − a)/(m −
1); and outputs the value of the interpolaton polynomial using only...
The problem demonstrates the use of the random number generator to recover previously generated random numbers Write a function called randi test that takes two scalar positive integer arguments maxi and n, and retums two output arguments: a row vector of n2 elements and and n-by-n matrix. The two output arguments must contain the exact same set of random integers that fall between 1 and maxi Do this using the random number genertor, not by reshaping the data Example n,v-randi...
matlab please
Problem 3. / 30 points Let p(x) = C1 +222 + ... + -1. The value of p for a square matrix input is defined as p(X) - 17+ 2X + ... + CX- (a) (12 points) Show that if XeRkxk has an EVD, then p(x) can be found using only evaluations of p at the eigenvalues and two matrix multiplications. (b) (18 points) Complete the following program which, given coefficients c = (C1,C2,...,C.)", evaluates the corresponding polynomial...
Please use MatLab and comment code.
Problem 2 Write a MATI AB user-defined function y-M?SotxType): x is a vector containing numbers. and Type can be 'Ascending' or Descending'. This function should sort the given vector x in the ascending or descending order based on the user's request and return the desired vector as the output. Do not use MATLAB built-in function sort. Hint: When you call this function you need to use for Ascending or Descending since they are strings.
I need a quick solution please :(
1 points Save Answer Let U, VER. Define addition and scalar multiplication on u =(x.y), v = (4.b) by u + v = (x+0.y+b), ku =(ky,box). Then V =R? with the defined addition and scalar multiplication, fails to be a vector space as A. It is not closed under scalar multiplication BU+V V+U c. 1uu D. There is no element, such that U+0=0+ U
matlab
1. Write a MATLAB user-defined function that finds the largest element(s) of a matrix. Name the function [max_value, max_index] - LASTNAMES matrix max (x), where input argument x is a vector or matrix (not a scalar), and the outputs are the maximum value(s) and indexes of the maximum value(s) of the mput x. Do not use MATLAB functions max() or find(). Use loops and if branches to determine the maximum elements of matrix. Check for correct number and valid...
1. in Matlab, write a user-defined function, with two input (r,theta) , θ expressed in degrees) and two output arguments (X,Y). The inputs are a location on a polar coordinates corresponding to Cartesian plane expressed in rectangular coordinates. The picture below describes the problem. X, Y rcos θ Some formula that you may need: x = r * cos (theta * pi/180); y r * sin(theta * pi/180); Test your code for r=7, theta=55° and present your results.
Question 1: Creating a user-defined function Write a user-defined MATLAB function named PBTask4pl_f.m for the following math function with x the input argument and y the output y(x)=0.8x4-13x2-5x The function should work for x being a scalar or a vector. Write a script file named PBTask4pl.m to a) Use the function to calculate y(3) and y(5) and display the results in command window b) Use the function to make a plot of the function y(x) for -5:5: x 5:5. Label...
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.
please do this problem in matlab and show me the code.
Thanks.please do this problem in matlab
and show me the code. Thanks.
please do this problem in matlab and show me...