Lewis Reeves
ELEC 2120 Signals & Systems
9/10/2024
Lab 1: Basic Decimal Matlab
Introduction:
This lab will revisit some basic MATLAB concepts and cover a few new concepts. The basic concepts will enable students to perform future MATLAB exercises more efficiently with less chance for error. Students will learn basics ranging from clearing the command window to calculating matrices and indexing.
Procedure:
1. Why do we clear the command window and workspace at the beginning of a script?
– We clear both the command window and the workspace at the beginning to get rid of any previous variables that may interfere with the new script.
2. Why would we use variables instead of just using the numbers, which is called hard-coding?
– We use variables so that we can reuse values and modify those variables more easily without having to modify every section where that value is used.
3. What system would you use to organize your variables and remember what each means?
– I prefer naming variables with a lowercase first word followed by an upper case shortened second word. For example: “firstNum” for a variable that comes first in a short list of numbers.
4. What are the benefits to using the array indexing approach?
– The benefit to using the array indexing approach is finding specific values in large datasets is much easier.
5. In your opinion, would the automatically-generated variable “ans” or a user-defined variable be more useful in writing scripts?
– A user-defined variable would be better than the automatically-generated variable “ans” for confidence and clarity.
Conclusions:
This lab successfully introduces students to the basics of MATLAB. Students will be better equipped for future MATLAB exercises.
I enjoyed refreshing myself on the basics of MATLAB and playing around with variables. I put some semicolons at the end of some lines because I forgot that semicolons hide the results from the command window, leading to wasting a few minutes finding the problem with my answers not showing. For future labs, I would include more explanations of common mistakes students make while using MATLAB such as the mistake I made.