Solve equation for one unknown with one known parameter

2 ビュー (過去 30 日間)
onur karakurt
onur karakurt 2021 年 5 月 18 日
コメント済み: Star Strider 2021 年 5 月 19 日
clear all
clc
a=0.5
x=linspace(-2*a,2*a,100)
eqn=@(x,y,a)(1/2*a^2)*[x^2./(2-(1-(x./(2*a))^2-(y./(2*a))^2)+sqrt((1-(x./(2*a))^2-(y./(2*a))^2)+(y./a)^2))-y^2./((1-(x./(2*a))^2-(y./(2*a))^2)+sqrt((1-(x./(2*a))^2-(y./(2*a))^2)+(y./a)^2))]-1==0;
solve(eqn,y)
Answer is
Unrecognized function or variable 'y'.
Error in naca (line 6)
solve(eqn,y)
how can I solve y for x matrix value
  2 件のコメント
onur karakurt
onur karakurt 2021 年 5 月 18 日
Also
ı dont want to use syms subprogram
value must be numerical
Star Strider
Star Strider 2021 年 5 月 18 日
The actual equations are:
I = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/621828/image.png');
figure
imshow(I)
.

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

採用された回答

Star Strider
Star Strider 2021 年 5 月 18 日
Try something like this —
a=0.5;
% x=linspace(-2*a,2*a,100)
x=linspace(-2*a,2*a,20);
eqn=@(x,y,a)(1/2*a^2)*[x^2./(2-(1-(x./(2*a))^2-(y./(2*a))^2)+sqrt((1-(x./(2*a))^2-(y./(2*a))^2)+(y./a)^2))-y^2./((1-(x./(2*a))^2-(y./(2*a))^2)+sqrt((1-(x./(2*a))^2-(y./(2*a))^2)+(y./a)^2))]-1;
for k = 1:numel(x)
yv(k,:) = fsolve(@(y)eqn(x(k),y,a), 10);
end
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient. Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
Results = table(x', yv)
Results = 20×2 table
Var1 yv _________ ______ -1 1.9833 -0.89474 2.1056 -0.78947 2.2028 -0.68421 2.2812 -0.57895 2.3444 -0.47368 2.3946 -0.36842 2.4335 -0.26316 2.4619 -0.15789 2.4805 -0.052632 2.4897 0.052632 2.4897 0.15789 2.4805 0.26316 2.4619 0.36842 2.4335 0.47368 2.3946 0.57895 2.3444
It might be necessary to use the uniquetol function to eliminate duplicate (or near-duplicate) values of ‘yv’ and thier associated ‘x’ values.
.
  9 件のコメント
onur karakurt
onur karakurt 2021 年 5 月 19 日
million thanks
Star Strider
Star Strider 2021 年 5 月 19 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by