Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #by FamiHug
- #this script solve quadratic equation
- function [root1, root2] = solve_quadratic(a,b,c)
- delta = b*b - 4*a*c
- if (delta > 0)
- root1 = (-b + sqrt(delta)) / (2*a)
- root2 = (-b - sqrt(delta)) / (2*a)
- elseif (delta == 0)
- root1 = (-b) / (2*a)
- else
- disp("Phuong trinh vo nghiem");
- endif
- endfunction #Matlab ko co dong nay
- solve_quadratic(1,5,6)#Không có ; ở cuối thì sẽ hiện ans
- disp(""); #in một dòng trắng
- solve_quadratic(1,5,6);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement