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!

답변 (2개)

Les Beckham
Les Beckham 2022년 2월 28일

0 개 추천

That sets the increment for the x vector.
Read the documentation for the colon operator: colon
Image Analyst
Image Analyst 2022년 2월 28일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 2월 28일

답변:

2022년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by