Files
matlab-learning/c_5_5_5.m
2025-10-10 17:29:33 +08:00

22 lines
388 B
Matlab

x=linspace(0,10,100);
y=[];
for x0=x
if x0>=8
y=[y,1];
elseif x0>=6
y=[y,5-x0/2];
elseif x0>=4
y=[y,2];
elseif x0>=0
y=[y,sqrt(x0)];
end
end
plot(x,y);
axis([0,10,0,2.5]);
title('分段函数曲线');
xlabel('Variable X');
ylabel('Variable Y');
text(2,1.3,'y=x^{1/2}');
text(4.5,1.9,'y=2');
text(7.3,1.5,'t=5-x/2');
text(8.5,0.9,'y=1');