Function and global variable
Show older comments
How to write these function and calling function?
Write a function, f_lab10, that will calculate this series approximation. Run your series code until the approximate percent relative error (apre) is below a specified error se = 0.01. Write a main or calling program, fcall_lab10, that will call f_lab10. You can hard-code se and x in fcall_lab10. Document f_lab10 and fcall_lab10 fully. In this lab, we want to compute the series approximation for each value in a vector x = [0:0.04:0.8]; so, in fcall_lab10 you will need a loop that will call f_lab10 once for each value in x. Store the approximation for each value of x in the vector sapprox that you will size before starting you loop, for example, sapprox = zeros(size(x)); Pass the value of x to f_lab10 as an input, pass se to f_lab10 using the Global Memory, and pass the series approximation from f_lab10 to fcall_lab10 as an output of f_lab10. An example of the first two lines of your function is as follows:
function series_approx=f_lab10(x)
global se
Thanks!!
1 Comment
TAB
on 9 Apr 2012
Looking like a homework question.
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!