How to make a function file that displays a polynomial and accepts a specific command?
조회 수: 1 (최근 30일)
이전 댓글 표시
채택된 답변
Rik
2022년 4월 15일
Why do you want to call your function like that? lou(a, b, c) will already work.
Anyway:
function lou(a,b,c)
if nargin==1,c=a(3);b=a(2);a=a(1);end
fprintf('%dx^2 + %dx + %d =0 \n',a,b,c)
end
댓글 수: 0
추가 답변 (1개)
KSSV
2022년 4월 15일
val = lou(1,2,3,.2)
function val = lou(a,b,c,x)
fprintf('%dx^2 + %dx + %d =0 \n',a,b,c)
val = a*x^2+b*x+c ;
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!