Solving non-linear equation in vector form
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
Hi all, hope you are doing well.
Soi have a simple equation where the known value is a vector. So i need to get a vector as the solution.
The equation is very simple and can be easily caluclated by hand but i require it to be solved using Matlab.
Here is the code i have tried:
u2 = rand(1,1000);
syms t1
eq = t1.^2/64 == u2;
solve(eq, t1)
Any help would be appreciated, thanks. 
댓글 수: 0
채택된 답변
  Matt J
      
      
 2021년 4월 28일
        
      편집: Matt J
      
      
 2021년 4월 28일
  
      If you have the Optimization Toolbox,
u2=[1,4,9];
opts=optimoptions('fsolve','SpecifyObjectiveGradient',true,'OptimalityTolerance',1e-12);
t1=fsolve(@(t1)objfunc(t1,u2),u2,opts)
function  [err, J]=objfunc(t1,u2)
  err=t1.^2/64-u2;
  J=speye(numel(u2))/32; %Jacobian
end
참고 항목
카테고리
				Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

