Solve MATLAB Homework: Find x1|t=0 for q=0.45

In summary: Your original problem was to perturb the initial conditions (IC's) in order to find the correct IC that would give x1(10)<0.45. Once you have found an IC that gives x1(10)<0.45, you can start halving the interval to find the IC that will give x1(10)>0.45. This process is called the "shooting method".
  • #1
dugironbeard
4
0

Homework Statement



dx(1)/dt=-0.1x(1)-x(2)
dx(2)/dt=x(1)-0.1x(2)

x1|t=0 = 1 , x2|t=0 =0

First we had to define the magnitude (q) of the velocity vector at t = 10.

The follow up question is:

The horizontal component x1|t=0 of the starting position is not known very accurately. However at t = 10 an accurate measurement of q=0.45 is known.

Determine the vvalue of x1|t=0 that leads to q=0.45

Homework Equations





The Attempt at a Solution




To find the initial q I made the following files in matlab.
clear,clc

x0=[1 0];
tspan=[0 1.01 10];
[t,x]=ode45('partb',tspan,x0);

x =

1.0000 0
0.4807 0.7656
-0.3083 -0.2002


function xp = partb(t,x)
t=10
x(1)=-0.3083
x(2)=-0.2002
xp(1)=(-0.1*x(1)-x(2));
xp(2)=(x(1)-0.1*x(2));
disp (xp(1))
disp (xp(2))
q=((xp(1)^2)+(xp(2)^2))^0.5
end

q = 0.3694

Now the problem is I don't know how to work backwards, I know I have to do something with fzero but I have to many variables. Any help would be greatly appreciated.
 
Physics news on Phys.org
  • #2
It's called the "shooting method". You need to perturbate the initial conditions (IC's) to search for the correct IC to get x1(10)=0.45.

Start by finding one IC that gives x1(10)<0.45 and one other that gives x1(10)>0.45 then just narrow it down using a "root search" algorithm of your choice, though for simplicity I recommend using "halving the interval".

Note that you have already found one IC that leads to x1(10)<0.45. So now just perturbate x1(0) to find an IC that leads to x1(10)>0.45 and you're good to start halving the interval.
 
  • #3
Thanks a lot for your reply uart.

Alright so first I am going to make a IC greater than 0.45. And than I have to write a root search algorithm.

Secondly really stupid maybe (English is not my native language), what is perturbate?
 
  • #4
dugironbeard said:
Thanks a lot for your reply uart.

Alright so first I am going to make a IC greater than 0.45. And than I have to write a root search algorithm.

Secondly really stupid maybe (English is not my native language), what is perturbate?

It was probably not quite the right word. I wish I could claim that English was not my native language. :redface: A perturbation in this context is just a "change in" or a disturbance in the initial condition. In other words just try x1(0) either a bit more than one or a bit less than one and see which way x1(10) moves. Once you get it moving in the correct direction then keep going until you get to x1(10) > 0.45, then you are ready to start halving the interval.

If you like you can initially just do the "halving the interval" manually, making a run of the DE simulation, calculating the new IC (halfway between the current two closest that are located on alternate sides of x1(10)=0.45) and then taking another run etc. You should be able to get an approximate solution fairly quickly like this. One you get the hang of what's happening then you can write some code to implement this "shooting method" automatically.
 
  • #5
Alright,

Well I am going back in tomorrow. Ill google a bit how to make a script for this shooting method.
 
  • #6
Right, next day.

I have found the initial values of between 1.15 and 1.25. Now to be honest I understand the intention of the shooting method but I have no clue whatsoever how to write it into a MATLAB code. Problem is I have two different files, one with the initial ode45 and the next one that takes it and calculates a velocity vector.

What I have now and not working:
clear,clc
a=1.20:0.0001:1.25
x0=[a 0];
tspan=[0 1.01 10];
[t,x]=ode45('partb',tspan,x0);
 
Last edited:

1. What is MATLAB and how is it used for solving homework?

MATLAB is a software platform that is commonly used for mathematical computations and data analysis. It allows users to write and execute code for various tasks, including solving homework problems. It has a user-friendly interface and a variety of built-in functions that make it a popular tool for scientists and engineers.

2. What does "x1|t=0" mean in the context of this MATLAB homework?

In this context, "x1|t=0" refers to the value of the variable x1 at time t=0. It is a specific point in time and the homework problem is asking for the value of x1 at that time.

3. What is the significance of q=0.45 in this MATLAB homework?

Q=0.45 is a value given in the problem that is used in the equation or function being solved. It represents a specific condition or parameter that is necessary for finding the solution to the problem.

4. How can I find x1|t=0 using MATLAB?

To find x1|t=0 using MATLAB, you will need to use the given equation or function and input the values of q=0.45 and t=0. The code should then be executed, and the resulting value of x1 will be the solution to the problem.

5. What steps should I take if I am having trouble solving this MATLAB homework?

If you are having trouble solving this MATLAB homework, the first step is to carefully read and understand the problem. Then, try breaking down the problem into smaller parts and solving each part individually. You can also consult online resources or seek help from a tutor or classmate. It is important to practice and familiarize yourself with the basics of MATLAB to effectively solve homework problems.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
825
  • Engineering and Comp Sci Homework Help
Replies
1
Views
954
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
996
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Advanced Physics Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
7
Views
1K
Back
Top