top of page

MATLAB Coding Project 1 - Quadratic Equation Solver

  • Writer: Mary Canlas
    Mary Canlas
  • Jan 28, 2022
  • 2 min read

Last year, as a foundation engineering student at the University of Nottingham, we were given a task to code a quadratic equation solver utilising MATLAB. Fortunately, with some previous coding knowledge (thank you GCSE computer science!), I was able to achieve a stellar 100%. This was my solution.


FEATURES OF THE CODE:


- The code can accept numerical expression inputs e.g (1/2) + 6^2, 3/6, 6*(9/10)

- The code can accept logical expression inputs e.g isnumeric(1) = 1, 1<7 = 1

- The code outputs aesthetically pleasing quadratic and linear equations

e.g if a = 1, b = -1, c = 0

the quadratic output would be "x^2 - x" rather than "1x^2 -1x + 0"

- The code handles pi, imaginary i & j when inputted e.g pi^0 = 1, i^2 = -1

- The code handles the abs function when used as an input e.g abs(-5) = 5

- The code handles errors regarding incorrect data type inputs

e.g numerical expressions with syntax errors e.g 1//2, 1-

e.g if certain data types are required, while loops and if statements are utilised until there is an acceptable input

- The code gives the user a choice to plot a graph of a straight line and find the intersections between the quadratic and linear equations

- The data on the legend of the graph changes depending on whether there are x-axis intersections/intersections between the quadratic and linear equations

e.g if there is no x-axis intersections, the 'x-axis intersection' label will not display on the legend

- On the graph, the x and y axis are plotted, displaying a 4 quadrant graph

- If the x-axis roots/points of intersection are not within the domain, the user will be informed


LIMITATIONS OF THE CODE


- If the co-ordinates are very close to each other on the graph OR if the domain is fairly small, the labels may overlap. However, zooming in on the graph or making the graph larger prevents this.






NOTE: I have not included all the x and y values in the screenshots


NOTE: I have not included all the x and y values in the screenshots



My final thoughts...


I thoroughly enjoyed this project. The satisfaction of something working, and the problem solving required is an aspect that allowed me to not find this task laborious. I want to hone my skills further, since I've been out of MATLAB practice for a while!


Thank you for reading this week, friends :) <3



コメント


© 2023 by Mary Canlas

bottom of page