Variables & Arithmetic Flashcards
(14 cards)
Clear command window
clc
Clear variables in workspace
clearvars
Assigning values to variables
Variable = value
How do we see all variables and their values?
Whos
How do we get strings?
Using quotation marks
w = “string”
What do we use for not showing results in command windows?
Use semicolon for not showing the output of a line.
x = 10 + 9 ;
What do we use for assigning multiple things in one line?
Use commas for using several variables in one line:
U = 20 , Me = 20
How do we run programs quickly?
Ctrl + Enter
How do we add comments?
Using percentage sign
% This is a comment
How to check the type of data of a variable?
By using the function “class”. This is how:
class(variable)
How to create structures like objects in python?
An example would be:
my_struct.name = “Aldair”
my_struct.age = 30
my_struct.gender = “male”
Some built in functions for structures?
isfield(my_struct, field)
rmfield(my_struc, field)
setfield(my_struct, field)
Can I set structures within structures?
Yes, like this (example)
my_struct.contact.phone
my_struct.contact.email
I created a field contact that is itself a structure that has two fields
Manually creating a structure?
my_struct = struct(field1, value1, field2, value2,…, field_n, value_n)