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

I write f(x)">

Question Details

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


Description

Answer Download


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

Uploaded by: Tutor

Answer rating:

This paper was answered on 21-Sep-2019

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Sep 21, 2019

EXPERT

Tutor

ANSWER RATING

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.

STUCK WITH YOUR PAPER?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now