フィルターのクリア

Find the minimum of a multi-variable function

30 ビュー (過去 30 日間)
emonhossain roy
emonhossain roy 2019 年 6 月 23 日
編集済み: infinity 2019 年 6 月 23 日
Question: Find the minimum of in the window [0,2]×[2,4] with increment 0.01 for x and y.
My approach:
syms fun(x,y) fx(x,y) fy(x,y) fxy(x,y) x y
=;
;
;
;
pt=solve([==0,==0],[x y]) But it gives me an error.
besides what about the window and increment mentioned that question. Any solution will be appreciated .
Thanks in advance .
  2 件のコメント
infinity
infinity 2019 年 6 月 23 日
Hello,
Could you provide your code and show us what is the error?
emonhossain roy
emonhossain roy 2019 年 6 月 23 日
code:
clc
clear all
syms fun(x,y) fx(x,y) fy(x,y) fxy(x,y) x y
fun(x,y)=x^2+y^2-2*x-6*y+14;
fx(x,y)=diff(fun(x,y),x);
fy(x,y)=diff(fun(x,y),y);
fxy(x,y)=diff(fx(x,y),y);
pt=solve([fx(x,y)==0,fy(x,y)==0],[x y])
error:
Warning: 4 equations in 2 variables.
> In C:\Program Files\MATLAB\R2013a\toolbox\symbolic\symbolic\symengine.p>symengine at 56
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 170
Warning: Explicit solution could not be found.
> In solve at 179
pt =
[ empty sym ]

サインインしてコメントする。

採用された回答

infinity
infinity 2019 年 6 月 23 日
編集済み: infinity 2019 年 6 月 23 日
Hello,
In your code, it was not good to put the name like "fun(x,y)". Also, we do not need to declare "fx, fun, fy,.." as symbolic variable. Here is a small code that you can refer
clear
syms x y
fun=x^2+y^2-2*x-6*y+14;
fx=diff(fun,x);
fy=diff(fun,y);
pt=solve([fx==0,fy==0],[x y]);
% pt=solve(fx==0,fy==0);
sol = struct2array(pt)
It will give us the solution
sol =
[ 1, 3]
I have run this code on Matlab2018a. Maybe in your Matlab version, there will be some different.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by