Getting Started with MATLAB
- Alexandra Bonnici
- 47 minutes ago
- 1 min read
This is a short introductory tutorial designed to provide a brief overview of fundamental MATLAB concepts, including basic arithmetic operations, graph plotting, scripts, and user-defined functions.
The tutorial intentionally incorporates common mistakes to expose students to typical error messages, helping them develop the ability to interpret and debug MATLAB code effectively.
Broken on Purpose: Can You Rescue This MATLAB Plot?
The following code is intended to generate a plot of an exponentially decaying sinusoid, similar to the one shown in Figure 1. However, the script contains three deliberate errors and will not execute correctly as written.
t = linspace(0, 10, 1000);
y = exp(-0.3*t)*sin(2*pi*t);
plot(y, T)
grid on
xlabel('Time')
ylabel('Amplitude')
title('Damped Oscillation')Your task is to identify and correct the errors so that the code runs successfully and produces the graph shown in Figure 1.

Curious to learn more about MATLAB? Let us know in the comments what you would like us to cover next.





Comments