I want to use fzero to do so, but I don't know how, since x is a matrix, rather than a symbolic function.
How to find zeros of a function?
869 次查看(过去 30 天)
显示 更早的评论
For instance,
x = -3.55:0.1:3.55;
y = x.^2 - 4;
Obviously, when x=2 or -2, y=0.
But I want to know how to use matlab to find zeros of a function y = f(x) when x is a matrix defined by the user like the above case.
3 个评论
Mark Sherstan
2018-12-17
Akira Agata
2018-12-17
If your function is always polynomial, you can use roots function to do this task. Please look at the following help page.
回答(3 个)
Wenjie
2018-12-17
3 个评论
Nico
2024-2-25
What does the @(x) and the 3 mean? Sorry I'm university student with no experience...
Alexander
2024-2-25
If it's not a function but meassured data I would go like this in a first try:
x = -3.55:0.0001:3.55; % assuming 10 kHz sample frequency
y = x.^2 - 4;
yS = sign(y);
dyS = diff(yS);
Z=find(dyS ~= 0);
x(Z)
Walter Roberson
2018-12-17
x(y==0)
Note that this can miss an indefinite number of zeroes of a function if the x do not happen to sample at the right places . It also will not detect zero crossings between x values . You could make use of the results to get hints about zero crossings .
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!