Create Arrays

In this exercise we will redo the calculation from the previous lesson but with composants to the initial conditions. You can use the last document but starting from scratch is also an option.

Lets first add some initial variables for the initial condition including some acceleration from some wind and an initial angle of attack:

image

The blue composant are added with either “[” or py pressing the element button in the Matrix dock on the right:

image

This looks a bit like making a name with a subscript, except its color coded with blue.
Like in the previous excervise we have made the variables p, v and a that just have two elements to them. If we insert a value in the function f and get the derived function like in the previous exercise we get:

image

The output of the function is now an array of two items.
As can be seen from this the velocity just moments before impact with the ground is more than 1000 km/hr. This is quite unreasonable. This is because we only added a very simplistic wind force as an acceleration. Lets try making a plot of the trajectory:

image

When inserting a function on both the X and Y value expressions, the plot automatically uses a new veriable for both functions. This is just happenstance that its the same value name as we used in the function. The plot will always use the name “t”, and it is also unitless. For this reason we need to multiply t with seconds to get the correct unit.

Instead of using the functions directly in a plot, we can also get the discrete values and plot those. Lets make an array and fill it with the datapoints from our function.

image

First we create a range and assign it to a variable i.t. The range expression “..” is created by either typing “;” or by pressing the Range button in the dock on the right.
This range will represent seconds in the dataset, but since we need whole numbers to set the indices in the variable F.data we need it to be unitless. Then we set the values in F.data, and here it is important to note that we are setting the values by putting the range i.t on the column and the values on the rows.

image

At first this might seem logical enough but there is a bit of magic going on behind the scenes.

image

As can be seen here the data that comes out of our function is in a column while each data element in the F.data matrix is in rows. This is because Symbolical figures out that the data is meant to go in rows from the sizes specified on the receiving end. Similarly you can do something like this:

image

So Symbolical is smart enough to align the data given from a function with the size of the element specified on a recieving matrix.

Had we just assigned F.data like F.data = f(i.t*s) then Symbolical would have tried to send the entire dataset of i.t into the function and the result would have been:

image

As can be seen here, Symbolical now tries to solve it with linear algebra, and those matrices do not match.
Lets try to plot the discrete values in F.data.

image

Plotting F.data is a bit like plotting the functions, but we just specify the subset of data to be used on the X and Y value expressions.

This file can be downloaded here Arrays.sbl

But what if we want to create a more physically correct trajectory by calculating the wind force?
Proceed to Solving Problems to find out!