can anyone find the error?

1 visualización (últimos 30 días)
Pawan Acharya
Pawan Acharya el 23 de Oct. de 2020
Comentada: Sindar el 24 de Oct. de 2020
and after RUN

Respuesta aceptada

Sindar
Sindar el 23 de Oct. de 2020
Perhaps you are calling the function with two few arguments, such as this on the command line:
quadraticc(2)
If you are simply hitting the "Run" button, then the program assumes no inputs at all, and b happens to be the first one it comes across.
Neither of these are bugs in the code, simply incorrect usage. If you want to prevent this, define defaults:
function quadraticc(a,b,c)
arguments
a (1,1) double = 1
b (1,1) double = 0
c (1,1) double = 0
end
  2 comentarios
Pawan Acharya
Pawan Acharya el 24 de Oct. de 2020
Sindar
Sindar el 24 de Oct. de 2020
you aren't calculating r when k<0, but you still try to display it

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 23 de Oct. de 2020
Editada: KSSV el 23 de Oct. de 2020
Save the function in a folder...and :
a = 1 ;
b = 2 ;
c = 3 ; % define your variables
quadratic(a,b,c)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by