作者zupo (朝着目标前进)
标题Re: [讨论]方程式求解(特定输入范围)
时间Sun Apr 30 07:55:13 2017
※ 引述《jim84jim84 (Weiso)》之铭言:
: 如果fun(x)=abs(abs(abs(x)-5)-2) 而x的范围:-5~7
: 若fun(x)=1 则我知道x的答案为-4,-2,-6
: 但我要如何以MATLAB实现上述的想法?
: 因为在网路上查到的function 像fsolve,solve好像只会传回一个输出
: 谢谢
本题需要先画出图形後观察零解起猜值
-----------------------------------------
function pttex147
x = -5:0.01:7;
x = x';
y = abs(abs(abs(x)-5)-2);
plot(x,y,x,y,'o')
Zerosolu = zeros(3,1);
% 由上图可看到变更零解起猜值的大约范围
x0 =[-4;2;6]
Zerosolu(1) = fsolve(@obj,x0(1));
Zerosolu(2) = fsolve(@obj,x0(2));
Zerosolu(3) = fsolve(@obj,x0(3));
Zerosolu
function f = obj(x)
f = abs(abs(abs(x)-5)-2);
-----------------------------------------
--
1.MATLAB programming 2.ASPEN process simulation package
3.FORTRN programming 4.Advance Engineering Mathematics
5.Process Control Theory
6.Chemical Engineering Basic Theory(Kinetic.thermodynamics.transport)
7.Numerical Method and Analysis
8.MATLAB Toolbox.Simulink system basic design
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.233.115.10
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MATLAB/M.1493510118.A.A7B.html
1F:推 hank850503: 推 05/04 10:25