

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Aerospace Practicum Introduction to MATLAB In-Class Practice Exercises
Complete these problems if you finish all of the in-class demonstrations before the laboratory is over. If you do not get to these in class, take a look at them during your own time, but you need not hand in these exercises with laboratory homework assignment #2.
Notes:
x^2 + y^2 = R^2 1.
Where R is the radius of the circle and x and y are coordinates. Plot a perfect circle with radius of unity using: a) MS Excel (be careful: you want your plot to look like a perfect circle, not an ellipse. This will require some manipulation on your part, it’s not that easy!) b) MATLAB using Cartesian coordinates. Hint: after you have generated your circle you can make it a perfect circle by making the scale of the axes equal by typing: axis equal. c) MATLAB using the polar function. Type: help polar, to explore this function. See if you can use this function to generate a perfect circle.
% 3D Plot - helix
plot3(X,Y,Z) xlabel ('x') ylabel('y') zlabel('z') title('Helix')
Notice the use of the ‘for’ loop and the counter k. Once you have typed this code in, run the code and save it as an m-file, named helix.m
function [Dir]=direction(m) lat=m(1); long=m(2); c1=cos(latpi/180); s1=sin(latpi/180); c2=cos(-longpi/180); s2=sin(-longpi/180); Dir=[c1s2,-s1,c1c2]';
This short script creates a new function called ‘direction’ that takes a two variable input, which are the latitude and longitude of a location. For example, Melbourne is at latitude of 28.1º and longitude of -80.6º. This corresponds to an input of x=[28.1, -80.6]. The function then converts this to a direction output. The direction output is an ijk unit directional vector relative to the center of the earth. Try this function by typing in the given x input and then typing: direction(x).