How to declare function?

조회 수: 2 (최근 30일)
Mustafa Alper YILDIZ
Mustafa Alper YILDIZ 2013년 10월 21일
댓글: Mustafa Alper YILDIZ 2013년 10월 21일
I'm trying to understand declaration of functions in Matlab. I want to compute
y(x)=x(sqrt(x)-sqrt(x-1)) for x= 10; 100; 1000;
And after declaring it as a function(.m) how can I call this function?
Thanks in advance

채택된 답변

sixwwwwww
sixwwwwww 2013년 10월 21일
편집: sixwwwwww 2013년 10월 21일
Dear Mustafa,
function y = calculate_sqrt(x)
y = x .* (sqrt(x) - sqrt(x - 1));
end
you can save it with the name "calculate_sqrt.m"
and then later you call it as
x = [10 100 1000];
y = calculate_sqrt(x);
I hope it helps. Good luck!
  댓글 수: 1
Mustafa Alper YILDIZ
Mustafa Alper YILDIZ 2013년 10월 21일
Thanks a lot. I got the idea :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by