## How to make a symmetric matrix from a muxed signal in MATLAB fcn block?

Hello,

I am developping a system that utilizes an MNA in simulink and need to use the fcn Block in order to calculate de correct PV tension.

I have 60 converters that are connected on a DC bus in a symmetrical format and manage to make the MNA work for a single side, but as soon as I use the variable I wrote the length of the muxed signal in for different points it gives me an error.

Here is the code I made:

function [UPV, Ibus]= fcn(IPV, Ubus)

R1 = 0.00748 / 2;

R = 0.00748;

n = length(IPV); %Logging the number of input in the muxed signal

d = floor(n/2); %Finding the end of the first side

e = d+1; %Start of the second side

G = diag(2/R * ones(n, 1)) + diag(-1/R * ones(n-1, 1), 1) + diag(-1/R * ones(n-1, 1), -1); %Making the impedance matrix.

G(1, 1) = 1/R; %Correction of the first resistor

G(d,d) = 1/R; %Correction of the resistor near the injection point on one side

G(e,d) = 0; %Removing resistor from injection point

G(d,e) = 0; %Removing resistor from injection point

G(e,e) = 1/R; %Correction of the resistor near the injection on the second side

G(n, n) = 1/R; %Correction of the last resistor

B = zeros(n, 1);

B(d) = 1;

B(e) = 1;

A = R1;

MNAG = [G -B; B’ A]; %MNA matrix

sources = [IPV(:); Ubus];

resultats = MNAG sources;

UPV = resultats(1:n);

Ibus = 2*resultats(n+1);

In the various iterrations of this code I managed to make the programm run but all output became NaN.Hello,

I am developping a system that utilizes an MNA in simulink and need to use the fcn Block in order to calculate de correct PV tension.

I have 60 converters that are connected on a DC bus in a symmetrical format and manage to make the MNA work for a single side, but as soon as I use the variable I wrote the length of the muxed signal in for different points it gives me an error.

Here is the code I made:

function [UPV, Ibus]= fcn(IPV, Ubus)

R1 = 0.00748 / 2;

R = 0.00748;

n = length(IPV); %Logging the number of input in the muxed signal

d = floor(n/2); %Finding the end of the first side

e = d+1; %Start of the second side

G = diag(2/R * ones(n, 1)) + diag(-1/R * ones(n-1, 1), 1) + diag(-1/R * ones(n-1, 1), -1); %Making the impedance matrix.

G(1, 1) = 1/R; %Correction of the first resistor

G(d,d) = 1/R; %Correction of the resistor near the injection point on one side

G(e,d) = 0; %Removing resistor from injection point

G(d,e) = 0; %Removing resistor from injection point

G(e,e) = 1/R; %Correction of the resistor near the injection on the second side

G(n, n) = 1/R; %Correction of the last resistor

B = zeros(n, 1);

B(d) = 1;

B(e) = 1;

A = R1;

MNAG = [G -B; B’ A]; %MNA matrix

sources = [IPV(:); Ubus];

resultats = MNAG sources;

UPV = resultats(1:n);

Ibus = 2*resultats(n+1);

In the various iterrations of this code I managed to make the programm run but all output became NaN. Hello,

I am developping a system that utilizes an MNA in simulink and need to use the fcn Block in order to calculate de correct PV tension.

I have 60 converters that are connected on a DC bus in a symmetrical format and manage to make the MNA work for a single side, but as soon as I use the variable I wrote the length of the muxed signal in for different points it gives me an error.

Here is the code I made:

function [UPV, Ibus]= fcn(IPV, Ubus)

R1 = 0.00748 / 2;

R = 0.00748;

n = length(IPV); %Logging the number of input in the muxed signal

d = floor(n/2); %Finding the end of the first side

e = d+1; %Start of the second side

G = diag(2/R * ones(n, 1)) + diag(-1/R * ones(n-1, 1), 1) + diag(-1/R * ones(n-1, 1), -1); %Making the impedance matrix.

G(1, 1) = 1/R; %Correction of the first resistor

G(d,d) = 1/R; %Correction of the resistor near the injection point on one side

G(e,d) = 0; %Removing resistor from injection point

G(d,e) = 0; %Removing resistor from injection point

G(e,e) = 1/R; %Correction of the resistor near the injection on the second side

G(n, n) = 1/R; %Correction of the last resistor

B = zeros(n, 1);

B(d) = 1;

B(e) = 1;

A = R1;

MNAG = [G -B; B’ A]; %MNA matrix

sources = [IPV(:); Ubus];

resultats = MNAG sources;

UPV = resultats(1:n);

Ibus = 2*resultats(n+1);

In the various iterrations of this code I managed to make the programm run but all output became NaN. mna, symmetric matrix, muxed signal MATLAB Answers — New Questions