本文介绍了如何在Matlab中使用exp查找功能的关键点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题,我希望有人可以在这里帮助我.我正在尝试查找该函数的所有关键点:

Quick question, I hope someone can help me out here. I'm trying to find all critical points of the function:

f(x,y) = 0.05 * (1-12x+20x^2) * (1-7y+10y^2) * exp(-(x^2/6+y^2/3))

当我执行通常的fx = diff(f(x,y),x)fy = diff(f(x,y),y)然后调用[xcr,ycr] = solve(fx,fy)时,它只给我一个解决方案...我知道还有更多解决方案.

when I do the usual fx = diff(f(x,y),x) and fy = diff(f(x,y),y) then call [xcr,ycr] = solve(fx,fy) it only gives me one solution...I know there are more then that.

这可能是因为存在无限数量的解决方案,而这是一个吗?有没有解决的办法?

Could this be because there are an infinite number of solutions, and this is one? Is there a way around this?

谢谢!

推荐答案

您没有共享确切的代码,所以我不知道为获得一个解决方案所做的一切,但是您可以使用符号工具箱来解决此问题小狗:

You didn't share your exact code so I don't know what you did to get only one solution, but you can use the symbolic toolbox to solve this puppy:

% # Define the function f(x, y)
syms x y
f = 0.05 * (1 - 12*x + 20*x^2) * (1 - 7*y + 10*y^2) * exp(-(x^2 / 6 + y^2/3));

% # Find the partial derivatives
f_x = diff(f, x);
f_y = diff(f, y);

% # Find the critical points
[xcr, ycr] = solve(f_x, f_y);
p = double([xcr(:), ycr(:)]);

% # Discard the complex solutions
p(imag(p(:, 1)) > eps, :) = [];
p(imag(p(:, 2)) > eps, :) = [];
p = real(p);

xcr = p(:, 1)
ycr = p(:, 2)

这实际上产生了13个解决方案:

This actually yields 13 solutions:

xcr =             ycr =

    0.5000            0.2000
    0.5000            0.5000
    0.1000            0.2000
    0.1000            0.5000
    2.6133            1.9238
   -2.3113            1.9238
    0.2980            1.9238
    2.6133           -1.5711
   -2.3113           -1.5711
    0.2980           -1.5711
    2.6133            0.3474
   -2.3113            0.3474
    0.2980            0.3474

这篇关于如何在Matlab中使用exp查找功能的关键点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 01:02