Professional Documents
Culture Documents
USE of Linspace Function and Incremental Method To Create A Vector A With N Equally Spaced Values. Example: Create A Vector A With 15
USE of Linspace Function and Incremental Method To Create A Vector A With N Equally Spaced Values. Example: Create A Vector A With 15
>> A=linspace(7,47.5,15)
A = Columns 1 through 9
7.0000 9.8929 12.7857
15.6786 18.5714 21.4643
24.3571 27.2500 30.1429
Columns 10 through 15
33.0357 35.9286 38.8214
41.7143 44.6071 47.5000
Number of increment 1
>> increment=(47.5-7)/(15-1)
increment = 2.8929
With this, 2.8929 is now assigned to be
the increment.
>> A=(7:increment:47.5)
A=
Columns 1 through 9
7.0000 9.8929 12.7857 15.6786 18.5714
21.4643 24.3571 27.2500 30.1429
Columns 10 through 15
33.0357 35.9286 38.8214 41.7143 44.6071
47.5000
>> B=linspace(7,23,Number);
>> B(18)
ans =
9.7200
(b)
>> B=(7:0.16:23);
>> B(18)
ans =
9.7200 stop
>> t=(0:0.02*pi:25*pi);
>> x=sin(t); y=cos(t); z=t;
>> plot3(x,y,z)
80
60
40
20
0
1
0.5
0
-0.5
-1
-1
-0.5
0.5