Calculating function output for more than one input variable

조회 수: 2 (최근 30일)
Beaya
Beaya 2013년 10월 27일
댓글: Beaya 2013년 10월 27일
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일
x = [1 4 5 10 20]
y = x.^2./(sqrt(x.^2+1.0)-1.0)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by