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
OUTPUT of the code
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...
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...
1)
a) Write MATLAB function that accepts a positive integer
parameter n and returns a vector containing the values of the
integral (A) for n= 1,2,3,..., n. The function must use the
relation (B) and the value of y(1). Your function must preallocate
the array that it returns. Use for loop when writing your code.
b) Write MATLAB script that uses your function to calculate the
values of the integral (A) using the recurrence relation (B), y(n)
for n=1,2,... 19...
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...
(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...
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
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 code please
0 solutions submitted (max Unlimited) Problem2 A staircase of height h is modeled by the parametric equations: x = rcos(1) y = rsin(1) -=- trix where r=h[2 + 5 sin(1/8)]/10, n=4, and h 50m is the staircase height. Make a 3-D plot (shown) of the staircase. (Create a vector , for the domain 0 to 2π and use the pi1ot3 command.) so so nd ion Your Script em of 11% iength of vector t is 40e, use,...
(1)Calculate the scalar curl of the vector field.
F(x, y) = sin(x)i + 6 cos(x)j
(2)
Let F(x, y, z) = (2exz, 3 sin(xy),
x7y2z6).
(a) Find the divergence of F.
(b)Find the curl of F.
-/3 points v MARSVECTORCALC6 4.4.017. My Notes Ask You Calculate the scalar curl of the vector field. F(x, y) = sin(x)i + 6 cos(x)j -/8 points v MARSVECTORCALC6 4.4.023. My Notes Ask You Let F(x, y, z) = (2x2, 3 sin(xy), x?y2z6). (a) Find...