format X=123456789012345* ogspace(1,5,5) 1.0e+4*1.0e+04米 1.2346e+0m1.21578912500 .Du010.00012345678901 .u12 0.001296°8021.234601123096789012590 0.01230.01234567890123 46e021.078021:02 .1255 01511231246+031009510 123461:00:51216+00:1064 Format Format Format Format short long long e short e
format • x=.123456789012345*logspace(1,5,5)' Format short Format long Format short e Format long e x?
Evaluating Functions 21 n=21 xlinspace(0, 1, n) xlinspace(o, 1, n) y=zeros(l, n) y=sin(X for k=l: n y(k=sin(x(k) vectorization end help elfun
Evaluating Functions n=21; x=linspace(0,1,n); y=zeros(1,n); for k=1:n y(k)=sin(x(k)); end n=21; x=linspace(0,1,n); y=sin(x); vectorization help elfun
Vectorization peed SI · Clarit Education
Vectorization • Speed • Clarity • Education
Example m=5 n=4*m+1; X=linspace(o, l, n) y-zeros(l, n a-x(I: m+1) y(1:m+1)=sin(2*pi*a) y(2*m+1:-1m+2)y(1:m); y(2*m+2n)=y(2:2*m+1 y=sin(2*pi* linspace(0, 1, 21)
0 5 10 15 20 25 - 1 -0.8 -0.6 -0.4 -0.20 0.2 0.4 0.6 0.81 Example m=5; n=4*m+1; x=linspace(0,1,n); y=zeros(1,n); a=x(1:m+1); y(1:m+1) = sin(2*pi*a); y(2*m+1: -1:m+2)= y(1:m); y(2*m+2:n)= -y(2:2*m+1); y=sin(2*pi*linspace(0,1,21)) ??
Displaying Tables--sprintf Sine Table. Prints a short table of sine evaluations cIc n=21; Sinetable m X=linspace(0, 1, n) y=sin(2*pi*×) Help sidetable disp() disp(k x(k sin(x(k))) disp( for k =1: 21 degrees=(k-1)*360/0n-1) disp(sprintf(%2.0f %3.0f %6.3f, k, degrees, y(k)) en d disp() disp(x(k) is given in degrees. disp(sprintf('one Degree =%5 3e Radians, pi/180)
% SineTable, Prints a short table of sine evaluations. clc n = 21; x = linspace(0,1,n); y = sin(2*pi*x); disp(' ') disp(' k x(k) sin(x(k))') disp('------------------------') for k=1:21 degrees = (k-1)*360/(n-1); disp(sprintf(' %2.0f %3.0f %6.3f ',k,degrees,y(k))); end disp( ' '); disp('x(k) is given in degrees.') disp(sprintf('One Degree = %5.3e Radians',pi/180)) Displaying Tables--sprintf Sinetable.m Help sinetable