matlab如何表示区间为自变量的分段函数?

syms h;
x=0:1:100;
k = (x>=h).*x + (x<h).*(x-(0.35-x).^2);
y=30.*pi.*(1./(k+0.441));
y

你可以这样来定义其函数。函数名 piecewise4()

function y=piecewise4(h)

for x=0:100

x=0:1:100;

k = (x>=h).*x + (x<h).*(x-(0.35-x).^2);

y=30.*pi.*(1./(k+0.441));

end

在命令窗口下,输入

>> h=10;y=piecewise4(h)  %回车

运行结果

温馨提示:答案为网友推荐,仅供参考
相似回答