필터 지우기
필터 지우기

Create An Array That Contains All the Values of F(x)? Help!

조회 수: 1 (최근 30일)
Steven
Steven 2013년 9월 19일
I have a function f(x) that equals x if x < 1 and x^2 elsewhere.
How would I go about putting all the values of f(x) into another array, named y, for example?

채택된 답변

Jan
Jan 2013년 9월 19일
And to be complete:
y = x.^2;
y(x < 1) = x(x < 1);

추가 답변 (2개)

James Tursa
James Tursa 2013년 9월 19일
y = x;
y(y<1) = 1;
y = y.*x;

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 19일
x=-5:5
y=(x<1).*x+(x>=1).*x.^2

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by