How can I rectify this error? 'Invalid use of Operator.' 'Too many Output arguements'
2 次查看(过去 30 天)
显示 更早的评论
affineTransformGauss calculates the mean and covariance of y, the transformed variable, exactly when the function, f, is defined as y = f(x) = Ax + b, where A is a matrix, b is a vector of the same dimensions as y, and x is a Gaussian random variable.
%Input
% MU_X [n x 1] Expected value of x.
% SIGMA_X [n x n] Covariance of x.
% A [m x n] Linear transform matrix.
% B [m x 1] Constant part of the affine transformation.
% x
%Output
% MU_Y [m x 1] Expected value of y.
% SIGMA_Y [m x m] Covariance of y.
function [mu_y, Sigma_y] = affineGaussianTransform(mu_x, Sigma_x, A, b)
%Code here
x=horzcat(mu_x,Sigma_x);
C=A*x;
[mu_y, Sigma_y]= (C+b)
end
%Code to call your function
mu_x= [7;3];
Sigma_x= [0.2 0; 0 8];
A=[1 1; 1 -1];
b=0;
%Calculate y
[mu_y, Sigma_y]=affineGaussianTransform(mu_x, Sigma_x, A, b)
5 个评论
回答(1 个)
VBBV
2023-3-20
%Input
% MU_X [n x 1] Expected value of x.
% SIGMA_X [n x n] Covariance of x.
% A [m x n] Linear transform matrix.
% B [m x 1] Constant part of the affine transformation.
% x
%Output
% MU_Y [m x 1] Expected value of y.
% SIGMA_Y [m x m] Covariance of y.
%Code to call your function
mu_x= [7;3];
Sigma_x= [0.2 0; 0 8];
A=[1 1; 1 -1];
b=zeros(length(A),1); % Make B as vector
%Calculate y
[mu_y, Sigma_y]=affineGaussianTransform(mu_x, Sigma_x, A, b)
function [mu_y, Sigma_y] = affineGaussianTransform(mu_x, Sigma_x, A, b)
%Code here
x=horzcat(mu_x,Sigma_x);
C=A.'*x+b; % calculate mean
Sigma_y = C;
mu_y = (sum(x)./length(Sigma_y)).';
end
Define the B vector as
b=zeros(length(A),1);
and compute the mean as
mu_y = (sum(x)./length(Sigma_y)).';
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!