필터 지우기
필터 지우기

How to solve equation with n data and select the maximum value of each answer?

조회 수: 1 (최근 30일)
I have a vector(A) with 2000 different values(1*2000).
I want to solve equation below and for each value of A I have two different answers and maximum value is desired. so I want 2000 answer for x.
(A/x)+x-200=0
The codes below has been used, but gives me wrong answer :
syms x
for i=1:2000;
eqn(1,i)=(A(1,i)/x)+x-200==0
answer(1,i)=max(solve(eqn(1,i),x)
end
can you please advise?
thank you

채택된 답변

Torsten
Torsten 2016년 2월 10일
answer(1,:) = 100 + sqrt(100^2-A(1,:));
Best wishes
Torsten.

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2016년 2월 10일
편집: Andrei Bobrov 2016년 2월 10일
n = numel(A);
out = zeros(n,1);
for jj = 1:n
out(jj) = max(roots([1 -200 A(jj)]));
end

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by