Lessons from CST exercise - PowerPoint PPT Presentation

About This Presentation
Title:

Lessons from CST exercise

Description:

can use any declaration form with quad or quadl area3 = quadl(ifname,0,pi) area3 ... cumarea(i) = quad(fname,xpts(1),xpts(i)); end % plot cumulative area. hold on ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 7
Provided by: jackp3
Learn more at: https://sites.pitt.edu
Category:
Tags: cst | exercise | lessons | quad

less

Transcript and Presenter's Notes

Title: Lessons from CST exercise


1
Declaring/using a function for evaluation
Engr 0012 (04-1) LecNotes 14-01
2
Finding maxima
no fmaxbnd command
can define new function
gtgt negfcn input('neg fcn name? gt ','s') neg
fcn name? neg_f13a
Engr 0012 (04-1) LecNotes 14-02
3
Finding maxima
call fminbnd with negative of function
Engr 0012 (04-1) LecNotes 14-03
4
Finding areas
easiest use quad or quadl
area quad(fname,xmin,xmax) or area
quadl(fname,xmin,xmax)
gtgt area1 quad(sfname,1.5,2.5) area1 0.1620
gtgt area2 quadl(mfname,1.5,2.5) area2 0.
1620
gtgt area3 quadl(ifname,0,pi) area3 0. 2086
can use any declaration form with quad or quadl
Engr 0012 (04-1) LecNotes 14-04
5
Finding areas
more complex and not as accurate!!! use trapz
area trapz(xtrap,ytrap)
need to define x y vectors of points
numtraps 100 xtrap xlow(xhigh-xlow)/numtraps
xhigh if string x xtrap ytrap
eval(sfname,x) if m-file ytrap
feval(mfname,xtrap) if inline ytrap
feval(ifname,xtrap) area trapz(xtrap,ytrap)
Engr 0012 (04-1) LecNotes 14-05
6
Finding ? f(x) dx over a range
objective is to create a vector of cumulative
area versus x value and then plot them on the
graph (i.e. area(x) vs x
create xpts for plotting xpts
xmin(xmax-xmin)/500xmax for i
11length(xpts) cumarea(i)
quad(fname,xpts(1),xpts(i)) end
plot cumulative area hold on
plot(xpts,cumarea,'g-')
Engr 0012 (04-1) LecNotes 14-06
Write a Comment
User Comments (0)
About PowerShow.com