Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is done in Matlab --------------------------------------------------------------------------------------------------------------------------- this is my previous program Problem 2: (i) Modify your previous programs such that Ivalue= myintegral|xg,wg,'myfunc') would compute the
This is done in Matlab
---------------------------------------------------------------------------------------------------------------------------
this is my previous program
Problem 2: (i) Modify your previous programs such that Ivalue= myintegral|xg,wg,'myfunc') would compute the same value Ivalue. You must use the Matlab command feval to call myfunc inside myintegral.m (ii) Run your new programs and print Ivalue. C: Users jacob Documents MATLAB Editor - C:\Users\jacob\Documents\MATLAB\myfunc.m myfunc.m xmyintegral.m X myscript.m X + function f=myfunc(x, y) 2- f=x^2+y^2; 3 end 1 1 C: Users jacob Documents MATLAB Editor - - C:\Users\jacob\Documents\MATLAB\myintegral.m myfunc.m myintegral.m x myscript.m X + function II=myintegral (xg, wg) 2 - ng=length (xg); 3- II=0; 4 for i=1:ng 5- for j=1:ng 6- II=II+myfunc(xg(i),xg (j)) *wg (i) *wg (j); 7 end 8 end - | 9 10 C: Users jacob Documents MATLAB Editor - C:\Users\jacob\Documents\MATLAB\myscript.m myfunc.m X myintegral.m myscript.mx + xg=[0, -0.77459666924148343, 0.77459666924148343]; wg=[0.8888888888888888, 0.5555555555555556, 0.5555555555555556]; Ivalue=myintegral(xg, wg) 1 | | | Command Window >> myscript Ivalue 11 2.6667 fx >> Problem 2: (i) Modify your previous programs such that Ivalue= myintegral|xg,wg,'myfunc') would compute the same value Ivalue. You must use the Matlab command feval to call myfunc inside myintegral.m (ii) Run your new programs and print Ivalue. C: Users jacob Documents MATLAB Editor - C:\Users\jacob\Documents\MATLAB\myfunc.m myfunc.m xmyintegral.m X myscript.m X + function f=myfunc(x, y) 2- f=x^2+y^2; 3 end 1 1 C: Users jacob Documents MATLAB Editor - - C:\Users\jacob\Documents\MATLAB\myintegral.m myfunc.m myintegral.m x myscript.m X + function II=myintegral (xg, wg) 2 - ng=length (xg); 3- II=0; 4 for i=1:ng 5- for j=1:ng 6- II=II+myfunc(xg(i),xg (j)) *wg (i) *wg (j); 7 end 8 end - | 9 10 C: Users jacob Documents MATLAB Editor - C:\Users\jacob\Documents\MATLAB\myscript.m myfunc.m X myintegral.m myscript.mx + xg=[0, -0.77459666924148343, 0.77459666924148343]; wg=[0.8888888888888888, 0.5555555555555556, 0.5555555555555556]; Ivalue=myintegral(xg, wg) 1 | | | Command Window >> myscript Ivalue 11 2.6667 fx >>Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started