clc;
clear all ;
%regula falsi method
f = @(x) (x^3-2*x^2+1.5*x); % the given function
n=0.1;
while (f(n)*f(-n) > 0) % here we are finding the the interval [a,b] where the f(a)f(b)<0
n=n+0.1;
end
a=-n; % f has a root in [a,b]
b=n;
%%%% here we are calculating the 1st approximation of the root c(1)
c(1)=(a*f(b)-b*f(a))./(f(b)-f(a)); % here we are using the Regula-Falsi method, c=(a*f(b)-b*f(a))/(f(b)-f(a))
if f(a)*f(c(1))<0 % if f (a) * f (c) < 0 then b = c else a = c
b=c(1);
else
a=c(1);
end
error=10;
i=2;
while (error>0.000001)
c(i)=(a*f(b)-b*f(a))./(f(b)-f(a)); % here we are using the Regula-Falsi method, c=(a*f(b)-b*f(a))/(f(b)-f(a))
if f(a)*f(c(i))<0 % if f (a) * f (c) < 0 then b = c else a = c
b=c(i);
else
a=c(i);
end
error=abs(abs(c(i)-c(i-1))./c(i)); % calculating relative error
i=i+1;
end
fprintf('The root with the relative error of 0.000001 is %f',c(end))


Consider the function f(x) = x3 – 2x2 + x Write the MATLAB code in the...
Given the equations write a Matlab Function File (code) for 10x1 + 2x2 - x3 = 27 -3x1 -5x2 +2x3 = -61.5 x1 +x2 +6x3 = -21.5 (A) Compute the determinant (B) Use Cramer's rule to solve for the x's (C) Solve by naive Gauss elimination. Show all steps of the computation.
NOTE: WRITE MATLAB CODE then the results for each QUESTIONS: Q1: For the system of the equations [2x; + 3xy + x3 = 9 x2 + 2x2 + 3x3 = 0 3x; +x2+2x3 = 8) compute the unknowns Xı, X2, and X3 using the inverse matris method. Q2: Simplify the complex number z and express it both in rectangular and polar form. (3+ j4)(5 + j2)(2 260°) (3+j6)(1+12) NOTE: WRITE MATLAB CODE then the results for each QUESTIONS: Q3: Suppose...
In MATLAB please
Consider the nonlinear function: y = f(x) = x3 cos x a. Plot y as a function of x as x is varied between -67 and 67. In this plot mark all the locations of x where y = 0. Make sure to get all the roots in this range. You may need to zoom in to some areas of the plot. These locations are some of the roots of the above equation. b. Use the fzero...
please solve then upload matlab code
Thanks
1. The function f(z, y) (a-x)2 + b(y-12)2 is called Rosenbrock's banana function. It is often used as a benchmarking test for optimization algorithms becatse it is easy to find the minimum by hand but often very difficult to find numerically. Throughout the problem, we will use the values a = 2 and b 10. You can plot this function using the following code: x3:0.1:3; y = -10:0.2:10; Cx,Ymeshgrid(x,y); Z(2-X).2 10* (Y-X. 2)....
The matlab code for the following problem is
appreciated!!
QUESTION 3 Write a function fnfr_plot that will receive two function handles from elementary math functions which accept a vector to first sort in ascending order then calculate. The script will display the results in two separate Figure Windows with the function names in the title. Submit: fnfr_plot.m Browse My Computer Attach File QUESTION 4 Generate 1x100 random vector, x in the range of 0<x<100 by using rand. Input 2 elementary...
Please I need help with MATLAB .. PLease help me . Thankyou Write Matlab code to plot a 2D sinc function over a 2D cartesian grid where x ranges from 100 to 355 and y ranges from 0 to 255 and the sinc is centered at somewhere not midway in the grid. First plot the grid, and then plot the function on the grid (both as grayscale and as a surface plot). Comment the code well, generate the figures and...
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...
DO
NOT GIVE ME A STEP BY STEP SOLUTION ON PAPER.
JUST GIVE ME THE MATLAB FUNCTION FILE (code) TO BE USED IN
MATLAB. ONLY
(a) use the Gauss-Seidel method to solve the following system until the percent relative error falls below s a. 5%. 10x1 + 2x2-x,-27 3x1 -6x2 + 2x3 61.5 25x321.5 b. (b) write an M-file to implement the Gauss-Seidel method using the above system as a test case
(a) use the Gauss-Seidel method to solve the...
Lab Exercises This lab assignment includes three items. You will write a file containing psuedocode, one Matlab function and one Matlab script. The script ca the function and your psuedocode must be robust enough to be a clear basis for the function and script files. The function you will write must implement the method of Naïve Gauss Elimination. Here is the official assignment: 1. Psuedocode Write psuedocode for a function implementing Naive Gauss Elimination. Save this pseudocode to a file...
Write a MATLab code for a function m-file that that can take three inputs (f, y, t) and uses a while loop to examine f(x) for x = y, x = y+2t, x = y+4t, ... until a number is larger than the previous value and returns the x value for which this happens. Notes: Assume that f is decreasing at x=y but that there is a cutoff x=b > y after which f starts increasing. Assume the input for...