========================PlottingData========================
>>t=[0:0.01:0.98];
>> y1=sin(2*pi*4*t);
>> plot(t,y1)

>> hold on;%plotnew figure on the old ones
>> y2=cos(2*pi*4*t);
>> plot(t,y2,'r')

>> ylabel('value')
>> legend('sin','cos')
>> title('my plot')
>> print -dpng 'myplot.png'%save as a file in default catalog
>> close

%分别显示两幅图像
>> figure(1);plot(t,y1);
>> figure(2);plot(t,y2)>>
%一幅图中显示两个subplot
figure
subplot(1,2,1);plot(t,y1)
subplot(1,2,2);plot(t,y2)
axis([0.5 1 -1 1])

A=magic(5)
imagesc(A)

>>imagesc(A),colorbar,colormap gray;

========================for if while statements========================
- > v=zeros(10,1)
- for i=1:10
- v(i)=2^i;
- end
- v
0
0
0
0
0
0
0
0
0
0
v =
2
4
8
16
32
64
128
256
512
1024
- indices=1:10;
- indices
- for i=indices, disp(i);
- end
- i=1;
- while i<=5,
- v(i)=100;
- i=i+1;
- end;
- v
- i=1;
- while true,
- v(i)=999;
- i=i+1;
- if i==6,
- break;
- end
- end
- v
- v(1)=2;
- if v(1)==1,
- disp('The value is one');
- else if v(1)==2,
- disp('The value is two');
- else
- disp('The value is neither one or two');
- end
- end
