Transformation of a MATLAB Function.
    9 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Fawad Khan
      
 il 13 Mar 2021
  
    
    
    
    
    Modificato: Fawad Khan
      
 il 14 Mar 2021
            I have a function defined as,
f_xw   = @(x,w) [3.*x(1) - x(1).^2/7 + w(1);
              -2.*x(2) + w(2)];
I want to transform this from x coordinate system to \eta coordinate system which would look like
f_etaw = @(eta,w) [3.*(c1+G1*eta) - (c1+G1*eta).^2/7 + w(1);...
                -2.*(c2+G2*eta) + w(2)];
where i define eta as symbolic variables 
eta = sym('eta',[2 1]);
and c's are constants numbers (1x1) and G's are constant row vectors (1x2) which i can define globally.
Is there a way to do this transformation using matlabFunction command? And can this transformation be made general for all functions with n states? 
0 Commenti
Risposta accettata
  Steven Lord
    
      
 il 13 Mar 2021
        f_xw   = @(x,w) [3.*x(1) - x(1).^2/7 + w(1);
              -2.*x(2) + w(2)];
f_etaw = @(eta,w) [3.*(c1+G1*eta) - (c1+G1*eta).^2/7 + w(1);...
                -2.*(c2+G2*eta) + w(2)];
So instead of x(1) you want to use c1+G1*eta and instead of x(2) you want to use c2+G2*eta?
% assuming c1, c2, G1, and G2 already exist
f_etaw = @(eta, w) f_xw([c1+G1*eta, c2+G2*eta], w);
And can this transformation be made general for all functions with n states? 
Assuming c and G are vectors that are the same size as the x input with which f_xw expects to be called:
% assuming c and G already exist
f_etaw = @(eta, w) f_xw(c+G*eta, w);
2 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

