MATLAB
LEC 2
ENG/Ahmed Atef
%s - print a string
%c - print a single character
%d - print a whole number
%f - print a floating point number
n - print a new line (go to the next line to continue printing)
t - print a tab
 - print a slash
%% - print a percent sign
http://www.cs.utah.edu/~germain/PPS/Topics/Matlab/fprintf.html
for i=1:10
disp(i)
end
for i=1:10
fprintf( '%f %d n',sqrt(i),i)
end
for x=0:pi/6:pi
fpirntf ('%0.3f %.2f n',sin(x),cos(x))
end
x=[0:pi/60:2*pi]
y=sin(x)
z=cos(x)
plot(x,y,'green .')
>Colour
Black
blue
cyan
green …
>Style
Single sign
pulse sign
circle
square
dianmond
+,>,.,-,--
,o,d,p,x,h
Ex:2
x=[0:pi/60:2*pi]
y=sin(x)
z=cos(x)
plot(x,y,'green -')
hold
plot(x,z,'blue -')
x=[0:pi/60:2*pi]y=sin(x)
z=cos(x)
plot(x,y,'green -',x,z,'blue -')
x=[0:pi/60:2*pi]
y=sin(x)
z=cos(x)
plot(x,y,'green -',x,z,'blue -')
legend('sing(x)','cos(x)')
grid on
xlabel('X Axis')
ylabel('Y Axis')
title('Graph test 2D')
Subplot(num of rows ,num of columns,box num)
Subplot(3 ,2,box num)
Box Num 2Box Num 1
Box Num 4Box Num 3
Box Num 6Box Num 5
x=[0:pi/60:2*pi];
y=sin(x);
z=cos(x);
subplot(3,2,1);
plot(x,y,'green -')
grid
subplot(3,2,4);
plot(x,z,'blue -')
grid
x=[-8:0.05:8]
y=x
r=sqrt(x.^2+y.^2);
z=sin(r)./r;
plot3(x,y,z,'m -');
title('3D Line Graph')
xlabel('X axis')
ylabel('Y axis')
zlabel('Z axis')
x=[-8:0.05:8]
y=x
[x,y]=meshgrid(x,y)
r=sqrt(x.^2+y.^2);
z=sin(r)./r;
mesh(x,y,z);
title('3D graph')
xlabel('X axis')
ylabel('Y axis')
zlabel('Z axis')
THANKS

Matlab introduction