How can I rectify this error? 'Invalid use of Operator.' 'Too many Output arguements'

1 Ansicht (letzte 30 Tage)
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 Kommentare
Romy Jemals
Romy Jemals am 14 Mär. 2019
I need [mu_y, Sigma_y] such that
mu_y & Sigma_y are matrixes of order m*1 and m*m ;through 'xy=Ax+b' where
A is a matrix of m*n,
x is [mu_x, Sigma_y] mu_x is n*1 and Sigma_x is n*n.
and B is a vector of m*1.
How shall I correct the mistake?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

VBBV
VBBV am 20 Mär. 2023
%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)
mu_y = 3×1
3.3333 0.0667 2.6667
Sigma_y = 2×3
10.0000 0.2000 8.0000 4.0000 0.2000 -8.0000
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)).';

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by