ME 305 Engineering Computer Applications

This course provides an introduction to engineering computer applications with specific emphasis on Matlab. Students learn how to navigate the Matlab environment and create professional engineering graphics. Programming is taught with application to numerical solution of mathematical and engineering problems. Prerequisites GE 206 and MTH 271.

This course provides an introduction to engineering computer applications with specific emphasis on Matlab. Students learn how to navigate the Matlab environment and create professional engineering graphics. Programming is taught with application to numerical solution of mathematical and engineering problems. Prerequisites: GE 206 and MTH 271.

General information

Textbooks

Kermit Sigmon. MATLAB Primer. Third Edition, 1993.

MATLAB Primer.

Harold Abelson and Gerald J. Sussman with Julie Sussman. Structure and Interpretation of Computer Programs. Second Edition. MIT Press, 1996.

Structure and Interpretation of Computer Programs.

Assignments

Assignment #1

  • Do the assigned reading.
  • Write an expression in a MATLAB Command Window that returns the numerical value 8.
  • Multiply the previous result, using the ans variable, by 3.
  • Compare the result, using ans, to 24. Does the comparison return 1 or 0? What does this mean?
  • Do spaces matter when you write an expression?
  • In MATLAB, is there a difference between the numbers 1 and 1.0?
  • Which computer hardware component stores lots of data, but is relatively slow.
  • Which type of language is MATLAB? High-level, Assembly Language, or Machine Code?
  • Which computer hardware component processes, stores, sends, and receives data?
  • Which numeral system do we use most often?
  • How many numbers can be described by a binary numeral system that has only three digits? (Hint: the base-10 number 1 has representation 001 and the base-10 number 2 has representation 010).
  • Take the weekly homework quiz.
  • Assignment #2

  • Do the assigned reading.
  • Write a program that has the following features:
  • it generates a random integer between 1 and 10,
  • it asks the user to input their guess of the number (use the input command ... type help input to learn about it),
  • if the user has guessed the correct number, it congratulates the user,
  • if the user's guess wass incorrect, it tells them they get a "strike," tells them if they were low or high with their guess, and prompts for a second guess,
  • it repeats this until they get either three "strikes," in which case they lose, or they guess the correct number.
  • Take the weekly homework quiz.
  • Assignment #3

  • Write a program that has the following features:
  • it finds the following products: \begin{align} 8 \begin{bmatrix} 6 \ 2 \ -1 \end{bmatrix}, && -3 \begin{bmatrix} 4 & -6 \ 3 & 27 \end{bmatrix}, && \begin{bmatrix} 5 & 3 \ 9 & 12 \end{bmatrix} \begin{bmatrix} 5 \ 2 \end{bmatrix}, && \begin{bmatrix} 13 & 3 & 135 \ -3 & 7 & -3 \ 0 & 35 & 1 \end{bmatrix} \begin{bmatrix} -4 \ 1 \ -3 \end{bmatrix}, \end{align} \begin{align} -3 \begin{bmatrix} 4 & -6 \ 3 & 27 \end{bmatrix} \begin{bmatrix} 0 & -1 \ -3 & 2 \end{bmatrix}, && \begin{bmatrix} 13 & 3 & 135 \ -3 & 7 & -3 \ 0 & 35 & 1 \end{bmatrix} \begin{bmatrix} 0 & -44 & -6 \ 0 & 1 & 16 \ 0 & 1 & 1 \end{bmatrix}; \end{align}
  • it defines an array x with values 1, 2,, ... ,1000;
  • it changes the value of the element of x that is at index 507 to equal 49.
  • it sums all the values of the new x array, and assigns the result to y.
  • if y is greater than 1e4 ($10^4$), display the string 'acheivement unlocked'. Otherwise, display the string 'no. just, no.'.
  • Let $x = 2 e^1 - 4 e^2$ be a vector in vector space $\mathbb{R}^2$. Using the standard basis $e=(e^1,e^2)$ for $\mathbb{R}^2$, write the vector's coordinate tuple $x_e$.
  • Derive the linear map $A: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ that is the change-of-coordinate matrix from the standard basis to the basis $b = (3 e^1, -1 e^2)$.
  • Write a matlab script that takes a vector coordinate tuple (array) x, in the standard basis $(e^i)$, transforms it to the $(b^i)$-basis, and assigns it to the vector coordinate tuple (array) y.
  • Turn in the homework in class on Wednesday.
  • Assignment #4

  • Write a script that estimates the standard deviation of a random variable that has a gaussian probability density function using the function randn. Generate a 20 by 1 array that contains elements that have an increasing number of samples for the estimate. The first element is the estimate after 10 samples, and each element thereafter is the estimate after 10 more samples.
  • Write a script that evaluates each element of an array and determines if it is positive, negative, or zero. Let the array be a 20 by 1 array of random integers (including zero) with uniform probability density function ranging from -5 to 5. When evaluating each element, if the element is positive, print +; if negative, print -; if zero, print 0.
  • Please turn in the homework in class, Wednesday 09/23.
  • Assignment #5

  • Write a program file that defines the function rect_int that performs numerical integration on input data as follows. Let there be four inputs: (1) data for the one-dimensional data array to be integrated, (2) delta_t for the scalar time steps between each data point, (3) lower time limit of integration, and (4) upper time limit of integration. Estimate the integral of data over time using the rectangular rule that you learned in calculus.
  • Use rect_int to estimate the integral of tanh from 0 to 3 using 100 rectangles.
  • Repeat problems 1 and 2, but create and use a function mid_int that uses the midpoint rule.
  • Repeat problems 1 and 2, but create and use a function trap_int that uses the trapezoid rule.
  • Compare and discuss the results.
  • Turn in your homework in class, Wednesday.
  • program file rectangular rule

    Assignment #6

  • Write a script that plots the upper half of a hemisphere of radius 5. Turn the edge colors off so that the mesh isn't shown. Use the hot colormap and use lighting. Use a colorbar.
  • Write a script that plots the function $e^{-r}, \cos{2\pi r}$, where $r$ is the radial coordinate $r = \sqrt{x^2 + y^2}$. Color the faces blue, turn edges off, and use lighting. Turn on a Grateful Dead album. Dive in.
  • Assignment #7

    Write a function with arguments a time array t, "data" y that is approximately sinusoidal, and the angular frequency of that data omega. The function should return an array [a1, a2, a3] where the elements of the array give the linear least-squares best-fit for the function $$y(t) = a_1 + a_2 \cos(\omega t) + a_3 \sin(\omega t).$$ Test your function on this data, which has angular frequency $\omega = 2\pi\ rad/s$. Your writeup should show the results of this, including a plot of the noisy data and your analytic least-squares approximation. (Note: this used to say $\omega = 1\ rad/s$, which was totally incorrect.)

    Assignment #8

    Write a script that numerically solves the differential equation $$ \ddot{x} + 2 \zeta \omega_n \dot{x} + \omega_n^2 x = f(t), $$ for $x(t)$. Let $f(t)$ be the function $$ f(t) = A \sin{\omega t}, $$ where $A$ is the drive amplitude and $\omega$ is the drive frequency. Use initial conditions $x(0) = 1$ and $\dot{x}(0) = 0$. Show a plot of $x(t)$ for the case that $\zeta = 0.5$, $\omega_n = 20 \pi\ rad/s$, $A = 1/2$, and $\omega = 10 \pi\ rad/s$.

    Assignment #9

  • Design the Butterworth filter below by choosing its parameters to meet the following design criterion: at $1, kHz$, the output amplitude is approximately $20%$ of the input amplitude. In order to aid in the design, simulate the response of the system to a sinusoidal input voltage $V_s(t) = A,\sin{\omega t}$ with $A = 10, V$, $\omega = 2000\pi$. Turn in your simulation code and a plot showing 5 steady-state periods of the input and the output signals.
  • Write and test a program (function) named text_to_code that converts an input string of English text to international Morse code. It should output an equivalent binary string of ones and zeros—a character for each "unit" of time—with a 1 representing the "on" state and a 0 representing the "off" state. A separate function code_to_blink should be written that takes the output of this string and displays a visual representation (e.g. blinking "light"). Finally, write a script that uses these two functions to visualize the Morse code of the following paragraph (from Kierkegaard's Purity of Heart is to Will One Thing).
  • steady-state Purity of Heart is to Will One Thing

    Is not despair simply double-mindedness? For what is despairing other than to have two wills? For whether the weakling despairs over not being able to wrench himself away from the bad, or whether the brazen one despairs over not being able to tear himself completely away from the Good: they are both double-minded, they both have two wills. Neither of them wills one thing, however desperately they may seem to will it.

    Assignment #10

    Write a function write_paragraph that writes a paragraph. It should take as its input the number of sentences in the paragraph and return as its output the sentences as a single string.

    Hint #1: "Teach" your function how to construct a sentence by giving it a sample text. You might consider using this text, which is Sartre's essay Existentialism is a Humanism. The m-file has a single variable text that is a single, long string of the entire text.

    Existentialism is a Humanism

    Hint #2: Build a graph that consists of nodes that are each word in the sample text and edges that represent the relation can be followed by. For example, the sample text contains the word merely five times. These five times, it is followed by the word an, means, disguising, voluntary, or formal, (notice the punctuation in the last of these).

    nodes edges can be followed by

    Hint #3: We can convert the large string to a cell array of words with the strsplit function. I recommend leaving the punctuation at the end of the words in which they appear in the text.

    Hint #4: We can initialize a directed graph (digraph) object in MATLAB with the function digraph (e.g. G = digraph;). We can add an edge (and any new nodes required for the edge) with the function addedge. Be sure to use it with a syntax like G = addedge(G, 'existentialism','is') that re-defines G.

    Hint #5: To initialize the write_paragraph function, randomly select a word from the graph with a capital letter as its first letter. Subsequent words should be added at random from those that are children (heads) of the current word (tail).

    Hint #6: In order to know how many sentences you've built, you must know whenever you have a trailing period at the end of the most-recently selected word.

    Hint #7: We cannot add an edge to the graph twice, and if we attempt to do so, MATLAB will return an error. This is problematic. One way to deal with this is to use the try block (see documentation).

    Hint #8: More information on graphs in MATLAB can be found here.

    Assignments

    No assignments found.

    Resources

    Class resources will be posted here throughout the semester.

    Homework, quiz, & exam policies

    Homework & homework quiz policies

    Weekly homework will be due in class on Wednesdays, and it will be turned in for credit.

    Working in groups on homework is strongly encouraged, but no copying is permitted.

    Exam policies

    The midterm and final exams will be in-class. If you require any specific accommodations, please contact me.

    Calculators will be allowed. Only ones own notes and the notes provided by the instructor will be allowed. No communication-devices will be allowed.

    The final exam will be cumulative.

    Grading policies

    Total grades in the course may be curved, but individual homework quizzes and exams will not be. They will be available on moodle throughout the semester.

    Homework quizzes 25% Midterm Exam 35% Final Exam 40%

    Academic integrity policy

    Cheating or plagiarism of any kind is not tolerated and will result in a failing grade (“F”) in the course. I take this very seriously. Engineering is an academic and professional discipline that requires integrity. I expect students to consider their integrity of conduct to be their highest consideration with regard to the course material.

    Correlation of course and program outcomes

    In keeping with the standards of the Department of Mechanical Engineering, each course is evaluated in terms of its desired outcomes and how these support the desired program outcomes. The following sections document the evaluation of this course.

    Desired course outcomes

    Upon completion of the course, the following course outcomes are desired

  • students will have a clear understanding of basic computer programming techniques;
  • students will understand data types, functions, conditionals, and loops;
  • students will be able to program in MATLAB;
  • students will be able to produce plots in MATLAB;
  • students will be able to import data into MATLAB, manipulate it, and plot it;
  • students will be able to do basic statistical analysis with MATLAB;
  • students will be able to solve differential equations numerically in MATLAB;
  • students will understand basic numerical analysis;
  • students will be able to use the symbolic toolbox in MATLAB;
  • Desired program outcomes

    The desired program outcomes are that mechanical engineering graduates have

  • an ability to apply knowledge of mathematics, science, and engineering;
  • an ability to design and conduct experiments, as well as to analyze and interpret data;
  • an ability to design a system, component, or process to meet desired needs;
  • an ability to function on multi-disciplinary teams;
  • an ability to identify, formulate, and solve engineering problems;
  • an understanding of professional and ethical responsibility;
  • an ability to communicate effectively;
  • the broad education necessary to understanding the impact of engineering solutions in a global and social context;
  • a recognition of the need for, and an ability to engage in life-long learning;
  • a knowledge of contemporary issues; and
  • an ability to use the techniques, skills, and modern engineering tools necessary for engineering practice.
  • Correlation of outcomes

    The following table correlates the desired course outcomes with the desired program outcomes they support.

    desired program outcomes
    A B C D E F G H I J K
    desired course outcomes 1

    Academic Honesty/Professionalism

    What is Academic Integrity?

    Saint Martin's University is a community of faculty, students and staff engaged in the exchange of ideas in the ongoing pursuit of academic excellence. Essential to our mission is a focused commitment to scholarly values and intellectual integrity, and a respect for the ideas, beliefs and work of others. This commitment extends to all aspects of academic performance. All members are expected to abide by ethical standards both in their conduct and their exercise of responsibility to themselves and toward other members of the community. As an expression of our shared belief in the Benedictine tradition, we support the intellectual, social, emotional, physical and spiritual nurturing of students.

    What is Academic Dishonesty?

    Saint Martin's University defines academic dishonesty as violating the academic integrity of an assignment, test and/or evaluation of any coursework. This dishonest practice occurs when you seek to gain for yourself or another an academic advantage by deception or other dishonest means. You have a responsibility to understand the requirements that apply to particular assessments and to be aware of acceptable academic practice regarding the use of material prepared by others. Therefore, it is your responsibility to be familiar with the policies surrounding academic dishonesty as these may differ from other institutions.

    The Acceptable Use of AI in Coursework

    Any use of technology that misleads a reviewer in assessing the student's mastery of a specific set of skills or knowledge is a type of intellectual dishonesty, that is, a type of cheating. Students who are unsure about the appropriateness of using an artificial intelligence tool (or "AI") must check with the instructor before using it. This includes the use of tools that generate text, images, video, code, and other works. If you are permitted by your instructor to use one or more AI tools in producing your work, you must disclose the use of that tool. You should say which tool you used and how you used it. Then if you use specific AI generated content (text, images, videos, audio, code, and so on) you must cite it in the style (APA, MLA, and so on) specified by your instructor.

    University-Sanctioned Activities

    If you are absent from class due to university-sanctioned activities, such as sports, it is your responsibility to request that the absence be excused; otherwise, the absence will be recorded as unexcused. Absent students are responsible for catching up with the class, and if any assignments are due on the day of the absence, it is your responsibility to turn in the assignments on time (prior to class). Assignments may be submitted as an attachment to the instructor's email address.

    Counseling and Wellness Center

    There may be times, as a college student, when personal stressors interfere with academic performance and daily life. The Counseling and Wellness Center supports students by addressing mental and emotional well-being with FREE and CONFIDENTIAL services. To schedule an appointment, call 360-688-2016, or email counselingcwc@stmartin.edu, or stop by the CWC (1st floor St. Raphael Center). If you would rather not go to the CWC or need support in the evenings and weekends, please consider using the TimelyCare app (timelycare.com/smusaints) to speak with a mental health provider, free, 24/7, from your phone or computer. We are honored to provide individual and group therapy to hundreds of students every year. Please reach out if you feel our services might support your wellness.

    Center for Student Success

    The Center for Student Success offers free academic services for all Saint Martin's students. The Center provides subject-area peer tutoring in science, technology, nursing, engineering, math, business, accounting, economics, world languages and other subjects. At the Writing Center, students meet with writing tutors to discuss their academic, personal, and professional writing. The Advising Center works with students on academic advising, connecting with campus support resources, transition and self-exploration guidance, personalized academic improvement plans, learning workshops, and support for changing majors. Disability Support Services is also located in the Center for any student with a disability who needs accommodations. For more information on the Center for Student Success, or to sign up for a tutoring, advising, or DSS meeting, see the website: https://www.stmartin.edu/directory/offices-departments-directory/center-student-success

    Saints Care

    Saints Care is a student support network bringing together campus partners—faculty, staff, families and students—to foster the success of each student in their navigation of campus life. Faculty, staff, students, and community members are welcome to submit a Saints Care Referral at https://www.stmartin.edu/saints-care for any reason; including, but not limited to:

  • Academic concerns
  • Personal health issues
  • Not attending classes
  • Death or health concerns in the family
  • Behavioral concerns or changes
  • Safety concerns
  • Personal, emotional, or financial issues
  • Substance use concern
  • Disability support or assistance, either short or long term, including medical accommodations
  • Disturbing, distressing, or disruptive behavior or statements
  • Suicide ideations (verbal and/ or written, including class assignments and social media)
  • Aggressive or violent behaviors
  • Stalking, dating or domestic violence
  • Diversity and Inclusion Statement

    Recognizing and embracing diversity is an essential part of academic life and learning. At Saint Martin's, our Catholic mission and Benedictine charism call us to welcome and embrace all who enter our university. We promote the transcendent dignity of the human person and commit ourselves to fostering an inclusive and global learning environment. Our respect for persons means we welcome the similarities and differences that comprise our students, faculty, and staff; we open ourselves to the profound change that different cultures, traditions, and beliefs can have on our practice of community; and we educate students to transform our world for peace and justice. We support our students in their navigation of university life, addressing issues of conflict through the ARC Reporting System (Accountability, Responsibility, and Community) to restore community. Saint Martin's offers multiple offices and resources to promote diversity across campus. The Chief Diversity Officer, Dr. John P. Hopkins, is available at jhopkins@stmartin.edu. All are welcome in the Dignity Center Lounge, located in Harned Hall, 207.

    Religious Accommodation Statement

    Saint Martin's University, in honor of the sacredness of the individual, and being deeply rooted in the Catholic Benedictine tradition of higher education, values the many religious and spiritual practices of our campus community. Saint Martin's University supports our students in their ongoing journey of becoming. In compliance with Washington State Law RCW 28B.137.010, Saint Martin's University reasonably accommodates students for reasons of religious observances.

    Access and Accommodations

    Your experience in this class is important to me. If you have already established accommodations with Disability Support Services (DSS), please communicate your approved accommodations to me at your earliest convenience so we can discuss your needs in this course. If you have not yet established services through DSS, but have a temporary health condition or permanent disability that requires accommodations (conditions include but are not limited to mental health, attention-related, learning, vision, hearing, physical or health impacts), you are welcome to contact DSS at 360-438-4580 or smu.dss@stmartin.edu. DSS offers resources and coordinates reasonable accommodations for students with disabilities and/or temporary health conditions. Reasonable accommodations are established through an interactive process between you, your instructor(s) and DSS. It is the policy and practice of Saint Martin's University to create inclusive and accessible learning environments consistent with federal and state laws.

    Sexual Misconduct/Sexual Harassment Reporting

    Saint Martin's University is committed to providing an environment free from sex discrimination, including sexual harassment and sexual violence. There are Title IX/sexual harassment posters around campus that include the contact information for confidential reporting and formal reporting. Confidential reporting is where you can talk about incidents of sexual harassment and gender-based crimes including sexual assault, stalking, and domestic/relationship violence. Confidential resources include the Counseling and Wellness Center (1st floor St. Raphael Center) or the Student Health Center (Burton Hall 102). These confidential resources can help you without having to report your situation to the formal reporting process via the Interim Dean of Students – Ms. Ann Adams, Title IX Coordinator & Associate VP of Human Resources – Ms. Cynthia Johnson, and/or Public Safety – Ms. Sharon Schnebly unless you request that they make a report. Please be aware that, in compliance with Title IX and under the Saint Martin's University policies, educators must report incidents of sexual harassment and gender-based crimes including sexual assault, stalking, and domestic/relationship violence. I appreciate that you feel comfortable talking with me. No one deserves to experience such behavior. Please know that our conversation is not confidential, but it is private. As someone who cares about your safety and well-being, I want you know that I have a responsibility to tell a member of the Title IX Team (listed above) so that he/she is aware and can provide you with information about options available to you regarding your safety and access to support services