how to pass function as argument ??

์กฐํšŒ ์ˆ˜: 3 (์ตœ๊ทผ 30์ผ)
david carlson
david carlson 2020๋…„ 5์›” 23์ผ
๋Œ“๊ธ€: KSSV 2020๋…„ 5์›” 24์ผ
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์ผ
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๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ MATLAB์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by