Develop an M-file for the bisection method. Along with the two initial guesses, pass the function as an argument.
i know how to develop M-file for bisection method but the problem i dont know how to pass the function as argument
ex : ๐’‡(๐’™)=๐Ÿ“๐’™^3โˆ’3x^๐Ÿ+2๐’™โˆ’๐Ÿ
how can i make a program that can read that equation as argument ??

 ์ฑ„ํƒ๋œ ๋‹ต๋ณ€

KSSV
KSSV 2020๋…„ 5์›” 23์ผ

0 ๊ฐœ ์ถ”์ฒœ

Read about anonymous functions.
f = @(x) 5*x^3-3*x^2+2*x-2 ;
Any value can be evaluated using:
f(1)
f(2)

๋Œ“๊ธ€ ์ˆ˜: 2

david carlson
david carlson 2020๋…„ 5์›” 23์ผ
i want to enter the function as [5 -3 2 -2] so matlab can record it as function of x
KSSV
KSSV 2020๋…„ 5์›” 24์ผ
Yes very much possible....when you enter like that, use polyval to evaluate the function at x.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

๋„์›€๋ง ์„ผํ„ฐ ๋ฐ File Exchange์—์„œ Programming์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

์ œํ’ˆ

๋ฆด๋ฆฌ์Šค

R2016a

ํƒœ๊ทธ

์งˆ๋ฌธ:

2020๋…„ 5์›” 23์ผ

๋Œ“๊ธ€:

2020๋…„ 5์›” 24์ผ

Community Treasure Hunt

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

Start Hunting!

Translated by