creak
幼苗
共回答了13个问题采纳率:84.6% 举报
原因使用solve函数求解方程组,如果返回多个参数,则参数是按照字母顺序排列,而与你在输入参数表中指定的顺序无关. 可参考关于solve函数的文档: Three different types of output are possible. For one equation and one
output, the resulting solution is returned, with multiple solutions to
a nonlinear equation in a symbolic vector. For several equations and
an equal number of outputs, the results are sorted in lexicographic
order and assigned to the outputs. For several equations and a single
output, a structure containing the solutions is returned.
建议一种方式是,修改solve函数的输出参数顺序:[C1,C2,C3,C4,D2,D3,D4,F1,F2,F3,F4,F5]=solve(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,'F1','F2','F3','F4','F5','C1','C2','C3','C4','D2','D3','D4')
或者,按照下面的方式返回参数:s=solve(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,'F1','F2','F3','F4','F5','C1','C2','C3','C4','D2','D3','D4');
fns = fieldnames(s);
for i=1:length(fns)
eval([fns{i} '=s.' fns{i}]);
end
1年前
2