(MATLAB) I have the file below with f(x) which calculates the integral of cos(x). How do

I write f(x)">

### [solution] » (MATLAB) I have the file below with f(x) which calculates the integral o

Description

The Question

(MATLAB) I have the file below with f(x) which calculates the integral of cos(x). How do

I write f(x) in another .m file?

trap.m file

`function trap( a, b, maxiter, tol ) m = 1; x = linspace( a, b, m+1 ); y = f(x); // f(x) is in another file approx = trapz( x, y ); disp(' m integral approximation'); fprintf(' %5.0f %16.10f n ', m, approx); for i = 1 : maxiter m = 2*m; oldapprox = approx; x = linspace ( a , b , m+1 ) ; y = f(x); approx = trapz(x, y); fprintf(' %5.0f %16.10f n ', m, approx); if abs( 1 - oldapprox/approx ) < tol return end end fprintf('Did not converge in %g iterationsn', maxiter)`

function trap( a, b, maxiter, tol )

m = 1;

x = linspace( a, b, m+1 );

y=f(x);

approx = trapz( x,y);

disp(' m integral approximation');

fprintf(' %5.0f %16.10f n ', m, approx);

for i = 1 : maxiter

m...

#### Solution details

Solution #00020422

##### [solution] » (MATLAB) I have the file below with f(x) which calculates the integral o.zip

This paper was answered on 14-Oct-2020

STATUS

QUALITY

Approved

Oct 14, 2020

EXPERT

Tutor

#### BEST TUTORS

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

• As a reference for in-depth understanding of the subject.
• As a source of ideas / reasoning for your own research (if properly referenced)
• For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.