MATLAB Answers

How ı can write this function on Matlab

1 view (last 30 days)
I will enter an x ​​value

  0 Comments

Sign in to comment.

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 4 Jun 2020
Hi,
Here is one of the possible solutions for x having a single value:
function Y = MY_fun(x)
if x>=1 && x<10
Y = exp(-x-1)/(log10(x)+log(x));
elseif x>=10
Y=sin(3*x)/sqrt(3*pi);
else
Y = x^(-exp(1)+x)+sqrt(x)*abs(x);
end
end

  13 Comments

madhan ravi
madhan ravi on 5 Jun 2020
Sulaymon comments:
%clc; % no need
%clear all; % no need
function Y=f(x) % Must be
% The rest comes here
end
Emre Tutucu
Emre Tutucu on 5 Jun 2020
thanks for your comment but i got it. wrong was not in code, in my matlab version. İts okay now.
Thanks again :)
Sulaymon Eshkabilov
Sulaymon Eshkabilov on 5 Jun 2020
Your code had a few potential errs which are not MATLAB version problem.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!