# Integrating MATLAB into the Physics Curriculum at Siena College

By Rose Finn, Siena College, Michele McColgan, Siena College, Graziano Vernizzi, Siena College, and Allan Weatherwax, Siena College

A principal goal of the physics program at Siena College is to prepare our students for careers or postgraduate study in physics or a related field. To support that goal, we have integrated MATLAB^{®} throughout the physics curriculum, beginning with the first semester of the first year (Figure 1).

Students build proficiency semester after semester, using MATLAB on the web to access MATLAB from any Internet-connected computer. Professors in upper-level courses can now focus on teaching relevant coursework rather than on teaching a new tool or language, and students can contribute immediately to research initiatives that require MATLAB experience.

## First-Year General Physics

In the fall semester, first-year physics students take a required course in mechanics. On their first day with MATLAB, they plot a sine wave, create an M-file, fit a function to data using `polyval`

, create a 3D plot, and publish their results. Later in the class, they use MATLAB to analyze experimental data collected during lab sessions spanning projectile motion, gravitational field strength, friction, circular motion, and momentum. They fit curves to the data to obtain a mathematical representation of the underlying theory, and plot the data to visualize the results. In one exercise, the students collected data from a simulation of a wave propagating along a string. After using MATLAB to plot this data, they created a sine wave in MATLAB and adjusted the frequency until it matched the measured data (Figure 2).

In the spring semester, the focus shifts to electricity, magnetism, waves, and optics. In this class, the students build on the MATLAB skills they acquired in the previous semester's mechanics course. Visualization exercises play a central role in the lab work. For example, students use MATLAB to plot the force vectors of an electric field (Figure 3). This exercise gives them a deeper understanding of vectors and how forces are combined.

In both courses, MATLAB on the web has simplified the grading of homework and lab assignments. Instead of collecting and managing dozens of emailed spreadsheets, professors now access student work online. We use the web interface to distribute examples, templates, and other course materials. On group projects, students can easily share work with their partners.

## Second-Year Computational Physics

The second-year computational physics course focuses on solving physics problems numerically. At this point, the students are comfortable using MATLAB for a range of computational tasks; they use MATLAB to calculate the eigenvectors and eigenvalues for a complex matrix as readily as students years ago computed a square root with a calculator.

In this course, the instructor uses MATLAB (in particular, MATLAB on the web) for virtually all class activities. During lectures, the professor displays MATLAB on an overhead screen, and students follow along on their own computers as he presents problems, tries various algorithms, and works through solutions. The students can immediately download the files the professor is demonstrating and use them to complete homework assignments.

The students tackle each problem presented using numerical methods in MATLAB. For example, they use ordinary differential equation solvers to analyze the two-body problem, which describes the orbit of one body under the gravitational influence of a significantly heavier body. They explore Newton's equations using the three-body problem. The students discover that such problems are difficult to solve analytically, but can be solved numerically in MATLAB with ease. Once they have visualized the differential equations of motion in MATLAB, they find the concepts much easier to understand.

The students also solve differential equations using the MATLAB `ode45`

suite and Symbolic Math Toolbox™. In one exercise, they determined that the next near-Earth passage of the 2011 AG5 asteroid would be in approximately 39 years, and created an animation of the event in MATLAB (Figure 4).

Later in the course, the students use MATLAB to compute integrals in many dimensions and to solve optimization problems with constraints. One student project focuses on the phenomenon of percolation, using Monte Carlo simulations in MATLAB to evaluate random walks for polymers in a solution with rigid obstacles (Figure 5).

Students implement the Floyd-Warshall algorithm in MATLAB to find the shortest paths in a weighted graph representing the Siena College campus (Figure 6). In the past, when students used a low-level programming language to explore optimization and similar concepts, too much of their time was spent on coding details. With MATLAB, they can focus on solving the physics of the problem.

## Advanced Mechanics, Electronics, and Astrophysics

The computational physics course is a prerequisite for several upper-level courses in the physics department, including electronics, astrophysics, and advanced mechanics and problem solving.

Students in the electronics course use MATLAB to analyze analog circuits with linear differential equations. For example, they create a mathematical model of a circuit with a capacitor and then plot the charge of the capacitor as a function of time. We found that using more sophisticated circuit simulators like SPICE for this type of analysis required a significant learning curve. With MATLAB the students can get started immediately, and are soon trying out new ideas or circuit configurations in an interactive environment.

In the project-based astrophysics class, students measure the fundamental properties of stars and galaxies by analyzing astronomy survey data. They apply the same techniques that astronomers use to calculate the distance to various galaxies or estimate their luminosity. They fit curves to the survey data and plot the results in MATLAB. Many students use the publishing features of MATLAB to create presentations of their work.

The senior-level problem-solving course introduces relativistic particles, the concepts of instability and chaotic behavior, and other advanced topics. The students use MATLAB for multiple assignments, including modeling linear filters, visualizing the motion of an electron in an electric field, and plotting the trajectory of masses in a swinging Atwood's machine (Figure 7).

## Research Readiness

Most ongoing research projects at Siena use MATLAB. Some also make extensive use of Simulink^{®} and HDL Coder™. Students' experience with MATLAB on the web enables a smooth transition to the desktop version of MATLAB and provides a solid foundation for getting started with Simulink.

We encourage all physics students to get involved with faculty research projects from their first year on. Several students have participated in the Firefly satellite project, a joint effort between Siena and NASA's Goddard Space Flight Center funded by the National Science Foundation. In this project, researchers are examining the link between lightning and sudden bursts of high-energy gamma rays in Earth's upper atmosphere. The Firefly satellite will carry a gamma ray sensor and an optical photo diode. The research team, including Siena faculty and students, uses MATLAB and Simulink to design digital filters and signal processing algorithms to process input from these sensors. The team generates synthesizable HDL code from the design for deployment to the FPGA that will fly aboard the satellite. The signal processing requires fast Fourier transforms, which are much easier to implement in MATLAB and Simulink than directly in HDL. The research team also uses MATLAB to develop analysis tools for post-processing data collected by the satellite during its mission.

## The Advantages of Curriculum Integration

In years past, upper-level classes at Siena College were fragmented; some students were more comfortable with spreadsheets, others with a particular programming language. This lack of uniformity was a challenge for professors, because no matter which tool was chosen for a course, there was always a subset of students who were unfamiliar with it. Faculty members who led summer research projects faced similar challenges because the students who joined the projects needed time to acquire the necessary MATLAB skills.

We overcame these challenges when we integrated MATLAB into the physics curriculum. This integration enables our students to develop practical skills—starting in their first year—that they will use not only throughout their undergraduate studies at Siena but for the next decade and beyond.

Published 2012 - 92015v00