例:
MATLAB程序如下:
clear
close all
clc
z2=zeros();
t=0:0.005:2;
for i=1:length(t)
if t(i)>=0&&t(i)<1
z2(i)=t(i)^2;
end
if t(i)>=1 && t(i)<2
z2(i)=t(i)^2-1;
end
end
运行结果:
例:
MATLAB程序如下:
clear
close all
clc
z2=zeros();
t=0:0.005:2;
for i=1:length(t)
if t(i)>=0&&t(i)<1
z2(i)=t(i)^2;
end
if t(i)>=1 && t(i)<2
z2(i)=t(i)^2-1;
end
end
运行结果: