採用された回答

Sindar
Sindar 2020 年 10 月 23 日

0 投票

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 日

1 投票

Save the function in a folder...and :
a = 1 ;
b = 2 ;
c = 3 ; % define your variables
quadratic(a,b,c)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2020 年 10 月 23 日

コメント済み:

2020 年 10 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by