- Generating a sequence of integers from 1 to 10.
>> n=1:10
n =
1 2 3 4 5 6 7 8 9 10
- Generating numbers from 0 to 1 with increments of 0.1.
>> t=0:0.1:1
t =
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
- Generating a row vector with 10 ones.
>> a=ones(1,10)
a =
1 1 1 1 1 1 1 1 1 1
- Generating a column vector with 5 zeros.
>> b=zeros(5,1)
b =
0
0
0
0
0
- Generating a 3x3 matrix with all elements equal to 3.
>> c=3*ones(3,3)
c =
3 3 3
3 3 3
3 3 3
- Generating 4 linearly spaced points between 5 and 10.
>> linspace(5,10,4)
ans =
5.0000 6.6667 8.3333 10.0000