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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by