square root on an interval

how to make a figure of the square root on the interval [0,2]. The figure should be smooth, not angular?

Answers (1)

One way is to use fplot()
f = @(x) sqrt(x)
fplot(f, [0 2])

4 Comments

thanks, but why do you use the @ in front of (x)?
This creates a function handle. Read about function handle here: https://www.mathworks.com/help/matlab/function-handles.html
okay thank you very much!
I am glad to be of help!!!

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Asked:

on 8 Nov 2020

Commented:

on 8 Nov 2020

Community Treasure Hunt

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

Start Hunting!