i want to create a function

it's gonna be named my_fun and it will sum up this: 1/i+1/((i+2)*(i+3))
for i=1 to N
help anyone?

 채택된 답변

Wayne King
Wayne King 2012년 1월 22일

0 개 추천

Have you read the Matlab Getting Started Guide?
Read Scripts and Functions under Programming:
Open the Matlab editor and declare your function.
function output = my_fun(N)
end
It seems to me that your user will input only N and then your function will do the rest of the work.
Write your code in the function body (between the function declaration and the end statement)
Save the function as my_func.m in a folder on the Matlab path and execute your function, ex:
>> outsum = my_func(10);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

질문:

2012년 1월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by