What does 1x0 empty double row vector mean?
When I do this operation 0:0.1, matlab turns 0 as a result.
But why does 1:0.1 turn 1x0 empty row vector? Should it not 1 since the operation will just give the first element, that is 1 but will not create others as uniformly spaced elements?

답변 (2개)

Rishik Ramena
Rishik Ramena 2020년 11월 5일

0 개 추천

If j > k, then x = j:k is an empty matrix.
You might want to go through the documentation for colon operator.
Sriram Tadavarty
Sriram Tadavarty 2020년 11월 5일

0 개 추천

Hi Metin,
In MATLAB, the colon operator indicates the range of values that are used for an operation.
lowestNum:HighestNum is the general usage.
In the case of 0:0.1, the lowest number is 0, the step size is 1 (by default) and the last number is 0.1. Since, its a valid range, the value of 0 is printed.
In case of 1:0.1, the lowest number is 1, the step size is 1 (by default) and last number is 0.1. Since, 1 cannot be made to 0.1, with a step size of 1, the value returned is empty.
You can try 1:-1:0.1, then the first value of 1 is printed, since there is a step size of -1 and it can go near 0.1.
For more information about colon operator, look here.
Hope this helps.
Regards,
Sriram

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2020년 11월 5일

답변:

2020년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by