Calculating function output for more than one input variable

I have this function y = x^2/(sqrt(x^2+1.0)-1.0) and I want to calculate it for several values of x but I don't know how to do this at once. Now I do it this way:
x = 8^-1
y = x^2/(sqrt(x^2+1.0)-1.0)
and I get my result but I don't want to repeat this every time I change the value of x. Is there a way to declare more values at once?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 27 日

0 投票

x = [1 4 5 10 20]
y = x.^2./(sqrt(x.^2+1.0)-1.0)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2013 年 10 月 27 日

コメント済み:

2013 年 10 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by