Solving non-linear equation in vector form
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Tayyab Khalil
      
 el 28 de Abr. de 2021
  
    
    
    
    
    Comentada: Tayyab Khalil
      
 el 28 de Abr. de 2021
            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 comentarios
Respuesta aceptada
  Matt J
      
      
 el 28 de Abr. de 2021
        
      Editada: Matt J
      
      
 el 28 de Abr. de 2021
  
      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
Ver también
Categorías
				Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!