clc;clear;
x0= [174 179 189 207 234 220.5 256 270 285];%原始数列 x0
n = length(x0);
lamda=x0(1:n-1)./x0(2:n)%计算级比
lamda = 1×8
0.9721 0.9471 0.9130 0.8846 1.0612 0.8613 0.9481 0.9474
range=minmax(lamda)%计算级比的范围
range = 1×2
0.8613 1.0612
x1 =cumsum(x0);%对原始数列 x0 做累加得到数列 x1
for i=2:n
z(i)=0.5*(x1(i)+x1(i-1));
end
B=[-z(2:n)',ones((n-1),1)];
Y=x0(2:n)';
u=B\Y %拟合参数
u = 2×1
-0.0663 162.8324
x=dsolve('Dx+a*x=b','x(0)=x0');
Warning: Support of character vectors and strings will be removed in a future release. Use sym objects to define differential equations instead.
x=subs(x,{'a','b','x0'},{u(1),u(2).x1(1)});
Dot indexing is not supported for variables of this type.
yuce1=double(subs(x,'t',[0:n-1]));
y=vpa(x)
yuce=[x0(1),diff(yuce1)]
epsilon=x0-yuce
delta=abs(epsilon./x0)
rho=1-(1-0.5*u(1))/(1+0.5*u(1))*lamda
上面是代码,最后运行出来是这样的
结构体内容引用自非结构体数组对象。
出错 ggg (line 14)
x=subs(x,{'a','b','x0'},{u(1),u(2).x1(1)});

Respuestas (1)

1 voto

你把逗号打成句号当然会有问题了
x=subs(x,{'a','b','x0'},{u(1),u(2).x1(1)});
这句改成
x=subs(x,{'a','b','x0'},{u(1),u(2),x1(1)});

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!