What's going on when setting these parameters?

So my question is quite simple.
I'm plotting, for example:
x=[0:0.1:4]
x = 1×41
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000
plot(x, sqrt(x), 'b.-')
title('Square root')
grid on
From trial & error I see that the numbers 0, 4 are my x-axis parameters, i.e. I'm printing the function for XE[0,5].
What exactly is the 0.1 for? What's that number doing? What's its purpose?
Thanks!

Answers (2)

That sets the increment for the x vector.
Read the documentation for the colon operator: colon
It's the step distance from one x value to the next. Look at your x values:
x = 0 0.1000 0.2000 0.3000 0.4000
See, they're 0.1 apart.

Products

Release

R2021b

Asked:

on 28 Feb 2022

Answered:

on 28 Feb 2022

Community Treasure Hunt

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

Start Hunting!