`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
f=@(y) y;
disp('Trapezoid method for f(y)=y');
trapezoid(f,1,3,20)
disp('Trapezoid method for f(y)=log(y)');
trapezoid(f,2,4,20)
function I = trapezoid(func,a,b,n)
% I = trap(func,a,b,n):
% multiple-application trapezoidal rule.
% input:
% func = name of function to be integrated
% a, b = integration limits
% n = number of segments
% output:
% I = integral estimate
x = a;
h = (b - a)/n;
s = feval(func,a);
for i = 1 : n-1
x = x + h;
s = s + 2*feval(func,x);
end
s = s + feval(func,b);
I = (b - a) * s/(2*n);
end
Note: Brother According to HomeworkLib's policy we are only allowed to answer first part if there are many. So, I request you to post other part as separate posts
Kindly revert for any queries
Thanks.
find trapezoidal rule and simpsons rule and error value for functions f(y)=y for yE[1,3] and f(y)=logy...
Show work by hand and also using MATLAB code. Model 1 Given a polynomial f(x) Write a first-order approximation of f(x), given the value of f(x) at two points Plot the polynomial and the first-order approximation on a graph Write a second-order approximation of f(x), given the value at three points. Plot the polynomial, the first-order and second-order approximations on a graph Find the integral Exactly Using trapezoidal rule Using composite trapezoidal rule Using Simpson's 1/3 rule . Calculate the...
Question: Code your own MATLAB program to find the approximate value of the Integeral 0 to 2 ex dx with Trapezoidal rule for N = 20, i.e., t20. Also give the relative error of t20 with Integeral 0 to 2 ex dx = e2 − 1. (Hint: For-end loops or Elementwise operations)
1. Numerical Integration The integral of a function f(x) for a s x S b can be interpreted as the area between the f(x) curve and the x axis, bounded by the limits x- a and x b. If we denote this area by A, then we can write A as A-f(x)dx A sophisticated method to find the area under a curve is to split the area into trapezoidal elements. Each trapezoid is called a panel. 1.2 0.2 1.2 13...
MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...
1,4,5 Multiple Choice (Find Output or Fix Error) 1. What will be the final value of product 7、 inta,b; Given above code, what will be the value of a andb if user types: 31 42 nt producr- 3, product 3 prodct while (product70) a) 81 31 What is the output of the following code? char Grade8 27 8. d) Error in do-while code 2. This loop is a good choice when you know how many times you want the loop...
NEED HELP ESPECIALLY ON C,D,E,F 2. [6pt] We attempt to find all solutions to f(x) = 0, where f(x) = e" – 3x – 1. (a) Sketch y = f(x) for -1 < x <3. How many solutions & does f(x) = 0 have? (b) Write code to implement the bisection method. Using the initial interval (1,3), write down the sequence of approximations X1, 22, 23, 24, 25 produced from your code. (c) What is the theoretical maximum value of...
I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding? b) (c) and (d) %% Matlab code %% clc; close all; clear all; format long; f=@(t,y)y*(1-y); y(1)=0.01; %%%% Exact solution [t1 y1]=ode45(f,[0 9],y(1)); figure; plot(t1,y1,'*'); hold on % Eular therom M=[32 64 128]; T=9; fprintf(' M Max error \n' ); for n=1:length(M) k=T/M(n); t=0:k:T; for h=1:length(t)-1 y(h+1)=y(h)+k*f(t(h),y(h)); end plot(t,y); hold on %%%...
3. Consider the functions \(f(x, y, z)=x y z\) and \(\mathbf{F}(x, y, z)=y z^{2} i+x^{2} z j+x y^{2} k\). Determine which of the following operations can be carried out and find its value:div \(f, \operatorname{grad} f,\) div \(\mathbf{F},\) curl div \(\mathbf{F}\) and div curl \(\mathbf{F}\).
MATLAB Question: Write a script for the problem pictured. Please send the script, not just the printout. Make sure your script allows you to input a value for n so when prompted, in the command window, user types n value. The n value should be the f_k if k ==1 .... Please also send print outs if you can. BELOW IS A SAMPLE ANSWER THAT DID NOT PUT THE INPUT SCRIPT NEEDED FOR THIS QUESTION TO BE CORRECT. YOU CAN...
This is for Controls Systems class. Please solve everything, and show all work and correct answers and matlab codes for positive rating. A - C, E - F do by hand. D, G-I do in Matlab as instructions direct. (Show codes and plots for matlab solutions too!), show the code and plots obtained for positive rating. Provided below is the Handout 7 equations that are needed for this problem for use. 1. The state space model of a system is...