Please find below the required MATLAB code. I have added comments at suitable places to explain the details. Further, I also plotted the two functions with respect to x values on x-axis to give an understnading of how function f are behaving with two definations.
Note that Q 6. has been solved through part 1 of the code and Q7 through part 2.
Please find below the selectable MATLAB code:
----------------------------------------------------------MAINFILE.M
clear all
clc
%% PART 1
x=[0:0.1:3];
% call function to compute function 1
for k=1:length(x)
result(k,:)=compute_f(x(k));
end
% display result table
fprintf('Result Table 1:\n')
disp(result)
% plot (x,f(x)) result to see how f(x) changes over x
plot(result(:,1),result(:,2),'r-')
title('Figure 1 using Anonymus Function 1')
clear x result
%% PART 2
% Calling Function 2
x=[1:0.5:10];
% call function to compute function 1
for k=1:length(x)
y=x(k)^2;
result(k,:)=compute_F2(x(k),y);
end
% display result table
fprintf('Result Table 2:\n')
disp(result)
% plot (x,f(x)) result to see how f(x) changes over x
figure
plot(result(:,1),result(:,2))
title('Figure 2 using Anonymus Function 2')
-------------------------------------------------- Function for computing QUESTION 6
function result=compute_f(x)
% Function for part 1
if x>=0 & x<1
f=x^3-x-2; % this f(x) will be used if 0<=x<1
elseif x>=1 & x<2
f=x^3-x-1; % this f(x) will be used if 1<=x<2
elseif x>=2 & x<=3
f=x^3-x; % this f(x) will be used if 2<=x<3
end
result=[x f]; % save result in two columns in form of
(x,f(x))
end
-------------------------------------------------FUNCTION FOR QUESTION 7
function result=compute_F2(x,y)
% Function for part 2
F=(10^(-3)*exp(x))/(sin(y^2)); % Function defination
result=[x F]; % save result in two columns in form of
(x,f(x))
end
-------------------------------------------
Note that bothe has been called from the mainfile.m.
------------------------------------- SCREENSHOT OF THE CODES
----------------------------------------------SAMPLE OUTPUT OF CODE
-------------------------------------------PLOT OF TWO FUNCTIONS For visual understanding of output
IN MATLAB 6. Construct Anonymous Functions to compute the functions below. Use the AFs within a...
Using MATLAB functions, write a program to answer the question 2) [6 pts] Consider the polynomial y x3-8x2 + 19x - 12 a) Create an anonymous function for y and use that for parts (b)-(d) b) Plot the function over the range 0 s x s 5. Use fplot. c) Find all zeros of the function d) Find the minimum point
Please help me with this matlab problem, the answer should look like the picture below. Thank you %1 Write an anonymous function that will receive data in the form of a plot function handle, x and y vectors, and a handle to a plot function and wil1 produce the plot. For example, a call to the function would look like the following: myPlot (@bar,x,y). x -pǐ : 0.25 : pi; y sin(x); % Piave you anonymous funcyion code here subplot...
For the following functions and using Boolean identities a) Simplify the given functions b) Construct the truth table for both of them showing the output of the original function and the simplified one and compare the two outputs? c) Draw the logic circuits for both the original function and the simplified one? 1. FIX, Y, Z) = X'+Y' + XY'Z 2. F(X, Y, Z) = (X+Y)(X' +Y+Z)
photo of the code please and an explnation if possible, Construct a simple MATLAB function program my_factorial which calculates product of first n positive integer numbers (i.e. find factorial n!). For full points: - Make sure you protect the code from illogical use (n must be positive integer) - Test the function by comparing with built in MATLAB function factorial(n) - Make sure you test your function for any limitations. O marks) -3. Using my factorial function from the previous...
1. Complete the table below for f(x)=3". Use exact values. No work needed. [1.25 points) - 101 y = f(x) 2. Consider the functions gtx)=(13)" and h(x) =--() +4 12.5,1.25, 1.5 points) a) The points given below (in the first column) belong to g(x)= - Perform two b) Use the point found in part a) to sketch a graph of y=h(x). Include the horizontal asymptote as a dashed line. Approximate point placement where necessary. transformations (and show how the points...
Design and construct a computer program in Java. The following is a plot of the function f(x) = sin(x3) + x2 : In order to illustrate the effects of the two major error sources, rounding and truncation, attempt to determine an approximation to the derivative of f(x) at x = 2.0 radians using the difference approximation given below. (The true answer is 4 + 12 cos(8) or about 2.2539995942966376896). Use the formula: f'(x) ≃ (f(x+h) - f(x)) / h with...
(1 point) Compare and discuss the long-run behaviors of the functions below. In each blank, enter either the constant or the polynomial that the rational function behaves like as x + Foo: 23 – 3 1. x4 – 3 f(x) = ar — x2 – 3 23 – 8 , and h(x) = 23 – 8' x3 – 8' f(x) will behave like the function y = as x + +0. help (formulas) g(x) will behave like the function y...
Model 1: Solving fory Most of the functions we have seen in this course are like those in Table 1 (and the first three functions in Table 2): They can be written explicitly in terms of x. That is, the function can be written as a single equation in the form y-... or, alternatively, f(x)-... in terms of x only Table 1 Table 2 Same function solved for vin terms of x only y=2x + 4 y=x3-3x2 + 13x-7 18x+5y...
Compute Laplace transforms of the following functions: (a) f1 = (1 + t) (b) f2 = eat sin(bt) 11, 0<t<1, (c) f3 = -1 1<t<2, | 2, t>2, Find the functions from their Laplace transforms: (a) Lyı] s(s + 1) (s +3) 2+s (b) L[42] = 52 + 2 s +5 (c) L[y3] = Solve the following initial value problems using the Laplace transform. Confirm each solution with a Matlab plot showing the function on the interval 0 <t<5. (a)...
Use Heun's Method please! Must use MATLAB and please use ANONYMOUS function. WIll rate answer 5 stars if done correctly. Use Heun's method (RK2), choose a step size Perform the same computation as in Prob. 28.19, but rather than using a constant wind force, employ a force that varies with height according to: 200z -2:/30 f(2) 5+z Problem 28.19 The following equation can be used to model the deflection of a sailboat mast subject to a wind force: d2 (L-z)...