Calculating function output for more than one input variable

9 Ansichten (letzte 30 Tage)
Beaya
Beaya am 27 Okt. 2013
Kommentiert: Beaya am 27 Okt. 2013
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?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 27 Okt. 2013
x = [1 4 5 10 20]
y = x.^2./(sqrt(x.^2+1.0)-1.0)

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by