Question

In: Advanced Math

Now that we have seen Euler in action, let's return to examining the content of the...

Now that we have seen Euler in action, let's return to examining the content of the M-File Euler.m. We have already explained the first line, where we defined the parameters our function takes. To see the meaning behind the third and fourth lines, type:

>> x = zeros(10,1);
y = zeros(10,1);
[x,y]

Thus we can see that the third and fourth lines of our M-File zero out the contents of our arrays x and y before we begin. Now, you'll continue examining our code.

Question: In your Word document, briefly explain what is happening in each remaining line of the M-File Euler.m.

The M-File is:

function [x,y] = Euler(h, x0, y0, interval_length, func)
nsteps = floor(interval_length/h) + 1;
x = zeros(nsteps,1);
y = zeros(nsteps,1);
x(1) = x0;
y(1) = y0;
for i=2:nsteps
    y(i) = y(i-1) + h* func(x(i-1), y(i-1));
    x(i) = x(i-1) + h;
end

Solutions

Expert Solution


Related Solutions

We have seen a couple of times now that action potentials occur because of the rapid...
We have seen a couple of times now that action potentials occur because of the rapid switching of places of sodium and potassium ions across a plasma membrane (“Na+ IN, K+ OUT”). The influx of sodium into a cell causes depolarization of the membrane; the efflux of potassium out of a cell repolarizes the membrane. In your own words, describe how excess extracellular K+ would affect this process, if at all.
We have seen that adding useless predictors to a regression model will increase R2. Here, let's...
We have seen that adding useless predictors to a regression model will increase R2. Here, let's examine what our inference methods say if the predictors are in fact useless. Suppose the true/pop fit is y = 1,(i.e., no x at all), and so a possible sample from the population could be the following: set.seed(123) n = 20 y = 1 + rnorm(n,0,1) a) Write code to make data on 10 useless predictors (and no useful predictors) each from unif(-1,+1), fit...
Let's now say we have $50 in a bank account and we deposit an additional $10 per month for 5 years.
Let's now say we have $50 in a bank account and we deposit an additional $10 per month for 5 years. The annual interest rate is 10%, compounded monthly. How much will we have in the account after 5 years rounded to the nearest dollar? A) $887 B) $692 C) $857 D) $665
We are going over ANOVAs and a question was raised "Let's imagine that we have a...
We are going over ANOVAs and a question was raised "Let's imagine that we have a research design looking at age of student (traditional versus non-traditional) and mode of learning (campus or online). What would the interaction be? What are the main effects?"
We have seen in lectures that if 50 people are chosen at random then there is...
We have seen in lectures that if 50 people are chosen at random then there is a 97% chance that at least two of them share the same birthday. Use similar calculations to answer the questions below. Assume that an ANU student is equally likely to have any one of 000 ... 999 as the last three digits of their ID number. (a) What is the percentage chance that in a working group of five students at least two have...
Consider some of the disaster events we have experienced or that you have seen in the...
Consider some of the disaster events we have experienced or that you have seen in the news during the past few years, occurring locally, across a state, nationally, or globally. What event do you think is most likely to be the next "big" disaster? Tell why you chose this event, and what you think the Public Health Response system's role should be in responding to it.
The past few weeks have seen unprecedented action in terms of both fiscal policy initiatives and...
The past few weeks have seen unprecedented action in terms of both fiscal policy initiatives and monetary policy initiatives. In terms of size, timing, and coordination this is the fastest and strongest both entities have acted to 'alter' the economy. Please take some time to read 3 or 4 articles if you are not familiar with these actions. Briefly summarize 5 fiscal policy initiatives put in place recently, and what the Fed did in terms of Monetary Policy. This week...
Let's say that we have two variables X and Y. We calculate their correlation value to...
Let's say that we have two variables X and Y. We calculate their correlation value to be r = -.8012. What is the interpretation of this value?
We now begin learningconcept in modern programming - Object Orientation Programming (OOP). Let's write our first...
We now begin learningconcept in modern programming - Object Orientation Programming (OOP). Let's write our first Class definition, and then instantiate an object of this Class to run in a test application to test our objects behaviors. Employee.java - Make an Employee Class, code to the design of the UML diagram -name: String -employeeId: int -Shift: Boolean -HourlyPay: double +Employee() +setName(n: String) +setemployeeId(i:int) +setShift(s:Boolean) +setHourlyPay(p:double) +getname() : String +getemployeeId() : int +getShift() : Boolean +getHourlyPay() : double +calculateOvertimePay( hours :...
Now that you have had a chance to review the content covered so far, take a...
Now that you have had a chance to review the content covered so far, take a moment to reflect upon what you have learned and post in this discussion board below. Consider one or two of the following statements in your post: Provide a real life situation that pertains to the information in Chapter 4 and 5. Why would knowing whether a linear relation exists be important? Where would this apply? Provide an example. Would it be important to know...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT