use fzero and quad to find area. I really need help with this one.!! Thank you so much guys

Assuming functions F and G have been previously defined. Give the matlab command that would compute and display the area of the closed region R.
function[fc]=Intersect(x,b,c); fc=F(x,b)-G(x,c); XL1=fzero(@F,0.7,[],b); XR1=fzero(@F,1,[],b); a=quad(@F,XL1,XR1,[],[],b); XL2=XR1; XR2=fzero(@G,1.5,[],c); b=quad(G,XL2,XR2,[],[],c); R=a+b that's what i put in the script file but it doesn't run properly and it still has error.

3 Comments

Jason, have you given this a try already? Can you attach your code and explain what difficulties you are having with it?
sorry about that.
function[fc]=Intersect(x,b,c);
fc=F(x,b)-G(x,c);
XL1=fzero(@F,0.7,[],b);
XR1=fzero(@F,1,[],b);
a=quad(@F,XL1,XR1,[],[],b);
XL2=XR1;
XR2=fzero(@G,1.5,[],c);
b=quad(G,XL2,XR2,[],[],c);
R=a+b
that's what i got but when i try to run it still has error.

Sign in to comment.

Answers (1)

fzero "fun accepts a scalar x and returns a scalar " But your F and G require two parameters, not one, so you cannot use them directly in fzero. And although you calculate fc, you do not use it.
Perhaps what you want is something like
fc = @(x) F(x,b) - G(x,c);
XL1 = fzero(fc, 0.7);

Categories

Products

Tags

No tags entered yet.

Asked:

on 16 Oct 2013

Answered:

on 17 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!