can anyone find the error?

조회 수: 1 (최근 30일)
Pawan Acharya
Pawan Acharya 2020년 10월 23일
댓글: Sindar 2020년 10월 24일
and after RUN

채택된 답변

Sindar
Sindar 2020년 10월 23일
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
Pawan Acharya
Pawan Acharya 2020년 10월 24일
Sindar
Sindar 2020년 10월 24일
you aren't calculating r when k<0, but you still try to display it

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2020년 10월 23일
편집: KSSV 2020년 10월 23일
Save the function in a folder...and :
a = 1 ;
b = 2 ;
c = 3 ; % define your variables
quadratic(a,b,c)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by