代码如下。
clear,clc
%*****************************绘图参数输入*********************************
fig_num=100; %绘制图片数量
a=linspace(0,20,fig_num); %调整曲线形状的常数
Sample_num=1000; %曲线数据点的数量
xrange_lower=-2; %曲线x范围的下限
xrange_upper=2; %曲线x范围的上限
xdata_lower=-1.8; %曲线数据x范围的下限
xdata_upper=1.8; %曲线数据x范围的上限
Color_Map=[255 192 203; %粉红
0 206 209; %暗宝石绿
233 150 122; %DarkSalmon
255 20 147; %DeepPink
255 255 0; %yellow
20 168 255; %blue
20 168 255;
255 255 0;
255 20 147;
233 150 122;
0 206 209;
255 192 203]; %存放曲线颜色的RGB值
%**************************************************************************
Color_num=size(Color_Map,1); %获取曲线颜色数量
Data_index=linspace(1,Sample_num,Color_num+1);
figure('position', get(0,'ScreenSize'));
for i=1:fig_num
%生成曲线数据
x=linspace(xdata_lower,xdata_upper,Sample_num);
y=abs(x.^(2/3))+exp(1)/3*(abs(pi-x.^2)).^(1/2).*sin(a(i)*pi*x);
%绘制曲线
for j=1:Color_num
plot(x(floor(Data_index(j)):floor(Data_index(j+1))),...
y(floor(Data_index(j)):floor(Data_index(j+1))),...
'Color',Color_Map(j,:)/255,...
'LineWidth',1.5);
hold on;
end
axis equal;
%绘制文字
text(-1.5,-1,{'From:','Name'},...
'Color',[238/255 99/255 87/255],'FontSize',35,...
'FontWeight','bold','FontName','Script MT bold');
text(0.8,-1,{'To:','Name'},...
'Color',[238/255 99/255 87/255],'FontSize',35,...
'FontWeight','bold','FontName','Script MT bold');
axis([xrange_lower xrange_upper -1.5 2.5]);
hold off;
fig_name=[num2str(i) '.jpg'];
saveas(gcf,fig_name);
end