(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?
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 );
approx = trapz( x,y);
disp(' m integral approximation');
fprintf(' %5.0f %16.10f n ', m, approx);
for i = 1 : maxiter
Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
About this QuestionSTATUS
Oct 14, 2020EXPERT
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).
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.