Ch.1 Notes
INTRODUCTION TO MATLAB
Friday, 19 January 2024
I found the 2017 identical to 2018 and 2019 for Ch.1, all having 14 pages. P.14 had exercises which I do below.
(P. G1) Referring to getting started and launching Matlab. I am now able to access the school’s remote, from
instructions on Canvas in 0 week Course Mtls (see below). Also, I downloaded “GUI Octave” to my computer.
Canvas Instructions
GUI Octave Logo
st
In
P.G1 Meeting the G1 Objectives
1. Mouse useage – Left/right click; drag; select; highlight (P.G1)
2. Typographical – Italic bold is text for me to input; (P.G2)
3. Create data file and working directories. (P.G3-G5)
G3 I created a “MyWork” Folder for each tutorial to come
G4 I downloaded to DataFiles from www.sdcpublications.com
4. G5 I set my working directory to go to MyWork folder
5. Download Video Files (These are also available on Canvas)
Doing these items I completed the GS section of the book and set my Google/Amazon device to do an hour for Ch.1
ru
P.1 Objective 1: Identify parts of the Matlab Screen;
N
or
ct
P.2 Objective 2: Enter Math Expression.
It creates a new variable “ans” in the workspace as shown
+ - * / ^
short format = 4 decimal spaces
Note: values are stored up to 16 digits of precision, can
be rounded or expanded by using format “Preferences”
P.3 Preferences & Using Help OR using the cmd prompt
short; long; shortE; longE; shortG; longG; shortEng;
longEng; + ; bank; hex; rat Eg. >>format long
Changing format “long” displays 16 digits (0.33333. . .)
Using “help” on “format” gives a library of formats avail.
P.4,5: Clearing the Command Window (use >>clc) and Workspace (>>clear) M
es
P.7: Data files use extension “.mat” i.e. “bearingdata.mat” is a 100 x 1
dimension data file meaning it is an array of 100 elements in one
column. All MatLab (ML) variables are array or matrix. Even one value
variable is a matrix >>data gives a list of the 100 numbers which are in
ounces. I am to convert each to grams. 1 oz = 28.35 grams
ot
P.5-6 Loading a File – Conversion Example
Error occurred when I mistyped folder
“Datafile”; changed path to “DataFiles”
It loaded a 100 column array in Workspace
Bearing Data ounces
Results of Loading & Converting Data File (P.6 - 7)
On the left, I loaded the bearing file, which called itself
“data” in the workspace. Then I did an operation on the
“data” file to convert it from grams to ounces on the
right, calling it “data_grams” Now I need to save the
new data_grams file so it can be later found in my folder
Bearing Converted Grams
st
In
P.8: Saving a .mat File
This always gets me in that the first file written after the save command is the file which I will newly named to go into
MyWork folder through that long path and, after the comma, is the data file that was created and saved in the
workspace in Octave. I used to get a lot of errors before understanding this for it not finding the directory.
P. 8 Arrow Up – gives Command History; also allows edit of previous command that gave an error w/o retyping.
ru
P.9 FUNCTIONS
NO FUNCTION
NAMES allowed as
variable names
Including: min;
max; bounds;
mean;
median;mode; std;
var; corrcoef; cov;
STATISTICAL FUNCTIONS ON data_grams (P.9)
N
or
ct
VARIABLES – starts w/ ltr; case sens;
Kwh2 is different than kwh2; 2kwh is
not valid (begins #)
NO KEYWORDS (“if” “end”) including
the following keywords: break; case;
catch; classdef; continue; else; elseif;
for; function; global; otherwise;
parfor; persistent; return; spmd;
switch; try; while;
Creating & Running a Script (P.10-13)
Terminal Velocity
% = comment line
Script files have “ .m “ extension
1.1 Converting closed-gate strength (20kN) and opengate (6kN) of the carabiner in lbf (1 kN = 224.809 lbf).
es
ot
P.14 – Exercises 1.1 – 1.4
1.2 - Converting oz to kg w/ bearingdata.mat; 1 oz = 0.0283495 kg.
1.3 – Calculate
ru
st
In
1.4 Terminal Velocity on Mars
es
ot
N
or
ct