看板 MATLAB 關於我們 聯絡資訊
※ 引述《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://www.ptt.cc/bbs/MATLAB/M.1493510118.A.A7B.html
hank850503: 推 05/04 10:25