Solve equation for one unknown with one known parameter

2 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by