Transformation of a MATLAB Function.
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Steven Lord
2021-3-13
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!