Student Notes · 2 Hours · MathWorks Onramp Modules 1–3
This session introduces you to the MATLAB programming environment. You will work entirely inside MathWorks Onramp — a browser-based MATLAB environment that requires no local installation.
By the end you will be able to type commands, create and name variables, perform arithmetic, and explain what each part of the MATLAB interface does.
MATLAB has four key areas. In Onramp, all of these are available in your browser window. Understanding where each one is will save you a lot of confusion during the exercises.
The >> prompt is where you type commands. Press Enter to run. Results appear immediately below your command. This is where you do all your work in Sessions 1–4.
Every variable you create appears here with its name, value, and type. Think of it as a whiteboard — it shows everything MATLAB currently remembers. Cleared when you close Onramp.
Plots and charts open here when you call plot(). You will use this from Session 3 onwards. For today, ignore it.
For saving sequences of commands. Introduced properly in Session 4. Scripts let you run and re-run code without retyping everything.
ans. It gets overwritten every time you run a new expression — so always name your variables properly.A variable is a named memory container. You create one by typing name = value and pressing Enter. MATLAB immediately stores the value and shows it in the Workspace panel.
After each line, look at the Workspace panel. You should see each new variable appear with its value. If you type the variable name alone and press Enter, MATLAB prints its current value.
Voltage and voltage are two completely different variables. Be consistent — pick a style and stick to it throughout a session.voltage = 400;) tells MATLAB to run the command but not print the result. Useful when you have many variables and don't want the screen flooded with output. You will use this more from Session 4 onwards.MATLAB figures out the data type automatically when you assign a value — you never need to declare it explicitly. For this session, everything will be a number.
Choosing good variable names is a professional habit, not just a MATLAB requirement. Clear names make code readable months later.
battery_voltage = 400
✅ VALID
lowercase, underscore separator — preferred style
PackCapacity = 75
✅ VALID
CamelCase also works
motor power = 150
❌ INVALID
spaces are not allowed in names
400voltage = 400
❌ INVALID
must start with a letter
Voltage ≠ voltage
⚠️ DIFFERENT
case-sensitive — these are two separate variables
end = 400
❌ RESERVED
end, for, if, while, function are MATLAB keywords
motor_torque, pack_voltage, cell_temperature. Avoid single-letter names like v or x — they tell nobody what the value represents.Every sensor on an electric vehicle produces a value. Every value needs to be stored, labelled, and used in a calculation. MATLAB variables are the mechanism that makes this possible.
The comments after each line (starting with %) document the unit and context. This is how professional engineers write MATLAB code — the unit is always noted.
Open your Onramp Command Window and complete the following four steps.
Create variables for battery_voltage (400 V), pack_capacity (75 kWh), and motor_power (150 kW). After each line, confirm the variable appears in your Workspace panel before continuing.
Using the variables you just created and the relationship P = V × I, write a single MATLAB expression that calculates max_current. Think carefully about units before you write the expression.
Display max_current in the Command Window. Check whether your result is physically reasonable for a high-power EV system. If something looks unexpected, review your expression and the unit of motor_power.
Think through the questions below before the group discussion. You do not need to write code for these — they are conceptual.
motor power) or name starts with a numbermotor_power. Names must start with a letter.name = value
% document your code — always note the unit of every variable
If an EV logs its speed every second over a 10-second test, you would need 10 separate variables: speed1, speed2 … speed10. A full WLTP drive cycle has 1800 data points. There has to be a better way to store all of that.
What do you think that better structure might look like? — Session 2 answers this.