关于符号变量的分段函数
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/07/05 16:10:18
关于符号变量的分段函数
function D = fcn(ut)
syms r
c1=0.5;
c2=0.0014;
c3=1;
R=100;
persistent a;
if isempty(a)
a=0.07;
end
if diff(ut)>0
h=max(ut-r,a);
elseif diff(ut) 0
h=min(ut+r,a); %ut的极小值点
a=h;
elseif diff(ut,2) < 0
h=max(ut-r,a); %ut的极大值点
a=h;
end
end
pr=c1*exp(-c2*(r-c3)^2);
D=int(pr*h,r,0,R);
D=subs(D);
为啥说
为啥说没定义h呢 h不是中间变量吗 该怎么写呢
function D = fcn(ut)
syms r
c1=0.5;
c2=0.0014;
c3=1;
R=100;
persistent a;
if isempty(a)
a=0.07;
end
if diff(ut)>0
h=max(ut-r,a);
elseif diff(ut) 0
h=min(ut+r,a); %ut的极小值点
a=h;
elseif diff(ut,2) < 0
h=max(ut-r,a); %ut的极大值点
a=h;
end
end
pr=c1*exp(-c2*(r-c3)^2);
D=int(pr*h,r,0,R);
D=subs(D);
为啥说
为啥说没定义h呢 h不是中间变量吗 该怎么写呢
![关于符号变量的分段函数](/uploads/image/z/8247937-49-7.jpg?t=%E5%85%B3%E4%BA%8E%E7%AC%A6%E5%8F%B7%E5%8F%98%E9%87%8F%E7%9A%84%E5%88%86%E6%AE%B5%E5%87%BD%E6%95%B0)
if isempty(a)
a=0.07;
end
h=[];
if diff(ut)>0
改成这样的试试,应该是在用h之前定义一个空矩阵
a=0.07;
end
h=[];
if diff(ut)>0
改成这样的试试,应该是在用h之前定义一个空矩阵