How to put max function in symbolic function

조회 수: 9 (최근 30일)
Mohamed Gaballah
Mohamed Gaballah 2021년 1월 13일
댓글: Mohamed Gaballah 2021년 1월 13일
I want to make a symbolic function where
f(x)=max(0,x)={0 x<0
x x≥0 }
how to do it?
syms x
f = max(0,x)
It gives me an error: Input arguments must be convertible to floating-point numbers.

답변 (1개)

Birdman
Birdman 2021년 1월 13일
Why would you try to name it as max? Simply, piecewise function in Symbolic toolbox would help you:
syms x
f(x)=piecewise(x<0,0,x>=0,x);
ıf you want to plot for specific inputs to test the function
x=-2:0.1:2;%random input
plot(x,f(x))
  댓글 수: 1
Mohamed Gaballah
Mohamed Gaballah 2021년 1월 13일
Isn't there an equivilant in Matlab 2016a , as it gives me "Undefined function or variable 'piecewise'."

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by