Finding vertex of a quadratic equation

6 views (last 30 days)
Lucas Woltjen
Lucas Woltjen on 13 Oct 2020
Edited: Ameer Hamza on 13 Oct 2020
Hello,
I am very new to MatLab and cannot figure out how to define variables and then call them into an equation to solve.
I was given the equation y=3x^2-6x+4
and how to find the x and y vertex:
Xvertex= -b/2a
Yvertex=a(Xvertex)^2+b(Xvertex)+c
I have tried using
a = 3;
b = -6;
c = 4;
Xvertex = -b/2*a;
Solve = -b/2*a;
Solve = a(Xvertex)^2+b(Xvertex)+c;
but I cannot figure it out. Any help would be greatly appreciated!

Answers (1)

Ameer Hamza
Ameer Hamza on 13 Oct 2020
Edited: Ameer Hamza on 13 Oct 2020
If you have the symbolic toolbox
syms x y
y = 3*x^2-6*x+4;
dy = diff(y);
Xvertex = solve(dy);
Yvertex = subs(y, Xvertex);
For your current code, following shows the mistake
a = 3;
b = -6;
c = 4;
Xvertex = -b/(2*a); % use brackets
Yvertex = a(Xvertex)^2+b(Xvertex)+c;

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!