whats wrong with my code

조회 수: 1 (최근 30일)
lana john
lana john 2020년 5월 23일
댓글: John D'Errico 2020년 5월 23일
function fact[a,b,c]=my_fact(x)
if x>0
s=1;
for i=1:x
s=s*i;
end
a=f
end
elseif x==0
b=1
elseif x<0
ms='enter a +ve number'
c=error(ms)

답변 (1개)

John D'Errico
John D'Errico 2020년 5월 23일
I wouldstart by saying this is not how you define a function.
function fact[a,b,c]=my_fact(x)
That is not valid syntax to define a function in MATLAB.
  댓글 수: 2
lana john
lana john 2020년 5월 23일
so how to define it?
John D'Errico
John D'Errico 2020년 5월 23일
You seem to be asking some pretty basic questions. Why not try reading the getting started tutorials?
Even so, rather than my writing how to define a function, you should read what is already written in a great deal of depth, here:

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by