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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by