Transformation of a MATLAB Function.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Fawad Farooq Ashraf
le 13 Mar 2021
Modifié(e) : Fawad Farooq Ashraf
le 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 commentaires
Réponse acceptée
Steven Lord
le 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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Function Creation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!