# Decision Making Using Fuzzy Discrete Event Systems

You can use a fuzzy discrete event system (FDES) for deciding between different outcomes in scenarios where discrete events can be modeled using a fuzzy transition matrix.

This example shows a sample FDES for clinical decision making in selecting medical treatments. A clinical decision-making system assists a medical practitioner in the diagnosis and treatment of a disease using relevant medical evidence. An FDES [1] allows continuous monitoring of the patient state to recommend a possible course of treatments for a disease [2]. This medical application in this example is for illustrative purposes and does not include real clinical data.

An FDES compactly and explicitly represents application-specific knowledge, even when the knowledge is imprecise or subjective. Also, an FDES model is not a black box. Rather, you can intuitively understand and validate the model structure and operational logic based on the event-transition matrices and related fuzzy state transfers. This model interpretability is important to many applications, especially those in medicine, as patient safety is paramount. Also, interpretability makes model design, development, refinement, and implementation easier, quicker, and more cost-effective.

This example performs decision making using single-event FDES models. You can also use multi-event FDES models for more complex treatment decision where each option consists of two or more different kinds of treatment.

### FDES Basics

An FDES complements a conventional discrete event system (DES) by using fuzzy sets and fuzzy logic. A conventional automaton model, which defines a DES, is extended to a fuzzy automaton to define an FDES as follows:

$$\mathit{G}=\left(\mathit{Q},\Sigma ,\phi ,{\mathit{q}}_{\mathit{o}}\right)$$

where:

$\mathit{Q}$ is a 1-by-$\mathit{N}$ vector that represents the overall system state using $\mathit{N}$ fuzzy states. Each fuzzy state in $\mathit{Q}$ can have membership values in the range [0, 1], as opposed to only 0 or 1 in conventional discrete event systems.

${\mathit{q}}_{\mathit{o}}$ is the initial fuzzy state vector.

$\Sigma $ is a set of fuzzy events, each of which is represented by an $\mathit{N}$-by-$\mathit{N}$ state-transition matrix. The elements of a fuzzy state-transition matrix can have values in the range [0, 1] rather than only 0 or 1. Therefore, the occurrence of a fuzzy event can produce a new overall system state $\mathit{Q}$ with partial membership values for the individual fuzzy states. An FDES can consist of one or more fuzzy events, which can be defined by domain experts or learned from available domain-specific data.

$\phi :\mathit{Q}\times \Sigma \to \mathit{Q}$ represents state transitions. The state-transition mapping uses fuzzy reasoning, such as the max-product composition method.

A conventional automaton is a special case of a fuzzy automaton while a discrete event system is a special case of a fuzzy discrete event system.

### FDES Model for Clinical Status

For this example, the treatment model uses an FDES for patients recently diagnosed with an aggressive, early-stage cancer.

The FDES represents the clinical status of the patient using four fuzzy states, each of which is defined by a fuzzy set.

*Healthy*— Fuzzy set with maximum membership or peak value at ${\mathit{x}}_{\mathit{h}}=4$*Good*— Fuzzy set with peak value at ${\mathit{x}}_{\mathit{g}}=3$*Fair*— Fuzzy set with peak value at ${\mathit{x}}_{\mathit{f}}=2$*Poor*— Fuzzy set with peak value at ${\mathit{x}}_{\mathit{p}}=1$

xPeak = 4:-1:1; statusStateNames = ["Healthy" "Good" "Fair" "Poor"]; showStateVector(xPeak,statusStateNames,"xPeak","Peak")

State vector, xPeak: Healthy Good Fair Poor _______ ____ ____ ____ Peak 4 3 2 1

$\mathit{Q}$ is the fuzzy state vector representing the patient status.

$$\mathit{Q}=\left[\begin{array}{cccc}{\mu}_{\mathit{h}}& {\mu}_{\mathit{g}}& {\mu}_{\mathit{f}}\text{\hspace{0.17em}}& {\mu}_{\mathit{p}}\end{array}\right]$$

Here:

${\mu}_{\mathit{h}}\in \left[0,1\right]$ is the membership value in

*Healthy*state.${\mu}_{\mathit{g}}\in \left[0,1\right]$ is the membership value in

*Good*state.${\mu}_{\mathit{f}}\in \left[0,1\right]$ is the membership value in

*Fair*state.${\mu}_{\mathit{p}}\in \left[0,1\right]$ is the membership value in

*Poor*state.

Lower values of ${\mu}_{\mathit{h}}$, ${\mu}_{\mathit{g}}$, and ${\mu}_{\mathit{f}}$, and corresponding higher values of ${\mu}_{\mathit{p}}$ indicate a more serious status of the patient.

To obtain a crisp health index value for the patient, you can defuzzify $\mathit{Q}$ using the centroid method. For more information on defuzzification, see `defuzz`

.

The resulting health index is in the range [1, 4], where a lower value indicates a more serious patient status.

#### Initial State

Before starting the treatment process, the initial clinical state of the patient is diagnosed as ${\mathit{q}}_{\mathit{o},\mathit{c}}$.

qo_c = [0 0.2 0.7 0.1]; showStateVector(qo_c,statusStateNames,"qo_c","Membership")

State vector, qo_c: Healthy Good Fair Poor _______ ____ ____ ____ Membership 0 0.2 0.7 0.1

The initial state vector represents the following crisp health index value ${\mathit{x}}_{\mathit{o},\mathit{c}}$.

`xo_c = defuzz(xPeak,qo_c,"centroid")`

xo_c = 2.1000

Hence, the patient is initially somewhat in the *Fair* state.

#### Events

Assume that the patient is considering the following two treatment options:

Surgery to remove the cancer

Radiation therapy to kill cancer cells

You can model each option as a single-event fuzzy discrete system.

Define the fuzzy state-transition matrix ${\alpha}_{\mathit{c}}$ for the surgery option.

```
alpha_c = [
1 0.8 0.1 0;
0.9 0.8 0.2 0.1;
0.1 0.6 0.3 0.2;
0 0.3 0.5 0.3];
showEventMatrix(alpha_c,statusStateNames,"alpha_c")
```

Event matrix, alpha_c: Healthy Good Fair Poor _______ ____ ____ ____ Healthy 1 0.8 0.1 0 Good 0.9 0.8 0.2 0.1 Fair 0.1 0.6 0.3 0.2 Poor 0 0.3 0.5 0.3

Each row of the transition matrix represents the possible surgery outcomes for a patient in a given state. For example:

A patient in a

*Fair*state will transition to a*Good*state with a likelihood of 0.6.A patient in a

*Good*state will transition to a*Poor*state with a likelihood of 0.1.A patient in a

*Poor*state will remain in a*Poor*state with a likelihood of 0.3.

Similarly, define fuzzy state-transition matrix ${\beta}_{\mathit{c}}$ for the radiation option.

```
beta_c = [
1 0.7 0.2 0;
0.7 0.6 0.4 0.3;
0 0.4 0.5 0.4;
0 0 0.7 0.6];
showEventMatrix(beta_c,statusStateNames,"beta_c")
```

Event matrix, beta_c: Healthy Good Fair Poor _______ ____ ____ ____ Healthy 1 0.7 0.2 0 Good 0.7 0.6 0.4 0.3 Fair 0 0.4 0.5 0.4 Poor 0 0 0.7 0.6

Comparing ${\beta}_{\mathit{c}}$ to ${\alpha}_{\mathit{c}}$ suggests that radiation therapy is a less effective treatment for this particular cancer. For example, in ${\beta}_{\mathit{c}}$, the possibilities for patients in a *Good* or *Fair* state to respectively transition to a *Healthy* or *Good* state significantly smaller than in ${\alpha}_{\mathit{c}}$. Furthermore, the possibilities for these two states to change to a *Fair* or *Poor* state are significantly higher than in ${\alpha}_{\mathit{c}}$.

#### State Transition

The patient state changes after the occurrence of an event. Each state-transition matrix, constructed using historical patient cases, represents the general clinical state transfer for all patients. When you apply the matrices to a new individual patient, the computed post-event fuzzy state is an estimation of the expected outcome. You cannot predict the actual treatment outcome in advance.

This example uses max-product composition to determine an expected post-event state. Expected state vectors are optionally normalized for comparison.

Compute the expected state ${\mathit{Q}}_{{\alpha}_{\mathit{c}}}$ after occurrence of event ${\alpha}_{\mathit{c}}$.

Qalpha_c = findNextState(qo_c,alpha_c); showStateVector(Qalpha_c,statusStateNames,"Qalpha_c","Membership")

State vector, Qalpha_c: Healthy Good Fair Poor _______ _______ _______ _______ Membership 0.18947 0.44211 0.22105 0.14737

Comparing ${\mathit{Q}}_{{\alpha}_{\mathit{c}}}$ with the initial state ${\mathit{q}}_{\mathit{o},\mathit{c}}$, the overall clinical state of the patient is expected to improve significantly after the surgery since the membership values for the *Healthy* and *Good* states increase, the membership value for Fair state (from 0.7 to 0.221), and a little change in Poor state (0.1 from 0.147).

Compute a crisp health index for ${\mathit{x}}_{{\alpha}_{\mathit{c}}}$ from ${\mathit{Q}}_{{\alpha}_{\mathit{c}}}$.

`xalpha_c = defuzz(xPeak,Qalpha_c,"centroid")`

xalpha_c = 2.6737

Similarly, compute the expected state ${\mathit{Q}}_{{\beta}_{\mathit{c}}}$ after occurrence of event ${\beta}_{\mathit{c}}$.

Qbeta_c = findNextState(qo_c,beta_c); showStateVector(Qbeta_c,statusStateNames,"Qbeta_c","Membership")

State vector, Qbeta_c: Healthy Good Fair Poor _______ _______ _______ _______ Membership 0.13333 0.26667 0.33333 0.26667

As compared to ${\mathit{Q}}_{{\alpha}_{\mathit{c}}}$, ${\mathit{Q}}_{{\beta}_{\mathit{c}}}$ has higher membership values for the *Fair* and *Poor* states but lower membership values for *Healthy* and *Good* states. Therefore, the overall clinical state of the patient after radiation would not be as good as after surgery.

Compute the crisp health index ${\mathit{x}}_{{\beta}_{\mathit{c}}}$ from ${\mathit{Q}}_{{\beta}_{\mathit{c}}}$.

`xbeta_c = defuzz(xPeak,Qbeta_c,"centroid")`

xbeta_c = 2.2667

To confirm this assessment compare the crisp health index values for each option. While both ${\mathit{x}}_{{\alpha}_{\mathit{c}}}$ and ${\mathit{x}}_{{\beta}_{\mathit{c}}}$ are higher than the original health index ${\mathit{x}}_{\mathit{o},\mathit{c}}$, the post-surgery index is higher than the post-radiation index.

### FDES Model for Quality of Life

While the surgery appears to be a better treatment option in terms of clinical status, it may have adverse effects on the long-term quality of life of the patient. For example, the following factors can impact a the post-treatment quality of life for the patient.

Known historical permanent medical problems caused by the treatment under consideration

Adverse effects from preexisting medical issues and the age of the patient to be treated

For this example, create a separate FDES for assessing the impact of treatment on the patient quality of life. Represent the expected long-term quality of life using three fuzzy states, each of which is defined by a fuzzy set.

*High*— Fuzzy set with peak value at ${\mathit{y}}_{\mathit{h}}=3$*Medium*— Fuzzy set with peak value at ${\mathit{y}}_{\mathit{m}}=2$*Low*— Fuzzy set with peak value at ${\mathit{y}}_{\mathit{l}}=1$

yPeak = 3:-1:1; qualityStateNames = ["High" "Medium" "Low"]; showStateVector(yPeak,qualityStateNames,"yPeak","Peak")

State vector, yPeak: High Medium Low ____ ______ ___ Peak 3 2 1

#### Initial State

Before starting the treatment process, the initial quality of life of the patient is assessed as ${\mathit{q}}_{\mathit{o},\mathit{l}}$.

qo_l = [0.1 0.5 0.4]; showStateVector(qo_l,qualityStateNames,"qo_l","Membership")

State vector, qo_l: High Medium Low ____ ______ ___ Membership 0.1 0.5 0.4

The initial state vector represents the following crisp health index value ${\mathit{x}}_{\mathit{o},\mathit{l}}$.

`xo_l = defuzz(yPeak,qo_l,"centroid")`

xo_l = 1.7000

Hence, the patient is initially somewhat in the *Medium* state.

#### Events

Define two more event matrices to model the treatment effects of surgery and radiation therapy on long-term life quality of life.

Transition matrix ${\alpha}_{\mathit{l}}$ represents the impact of surgery on quality of life.

```
alpha_l = [
0.6 0.8 0.3;
0 0.5 0.4;
0 0 1];
showEventMatrix(alpha_l,qualityStateNames,"alpha_l")
```

Event matrix, alpha_l: High Medium Low ____ ______ ___ High 0.6 0.8 0.3 Medium 0 0.5 0.4 Low 0 0 1

Transition matrix ${\beta}_{\mathit{l}}$ represents the impact of radiation therapy on quality of life.

```
beta_l = [
0.8 0.6 0.1;
0 0.9 0.2;
0 0 1];
showEventMatrix(beta_l,qualityStateNames,"beta_l")
```

Event matrix, beta_l: High Medium Low ____ ______ ___ High 0.8 0.6 0.1 Medium 0 0.9 0.2 Low 0 0 1

A comparison of the two matrices shows that the surgery can potentially induce more side effects than the radiation therapy can because:

The possibility (0.6) that a

*High*quality state remains unchanged after the surgery is lower than for radiation therapy (0.8).The possibility of a

*High*quality state to worsen to a*Medium*or*Low*quality state are higher for surgery.It is less likely that a

*Medium*quality state remains unchanged after surgery and it is more likely to worsen to*Low*quality state.

#### State Transition

Similar to the clinical status model, the expected long-term quality of life of the patient changes after treatment.

Compute the quality-of-life state after surgery ${\mathit{Q}}_{{\alpha}_{\mathit{l}}}$.

Qalpha_l = findNextState(qo_l,alpha_l); showStateVector(Qalpha_l,qualityStateNames,"Qalpha_l","Membership")

State vector, Qalpha_l: High Medium Low ________ _______ _______ Membership 0.084507 0.35211 0.56338

Compute the quality-of-life state after radiation ${\mathit{Q}}_{{\beta}_{\mathit{l}}}$.

Qbeta_l = findNextState(qo_l,beta_l); showStateVector(Qbeta_l,qualityStateNames,"Qbeta_l","Membership")

State vector, Qbeta_l: High Medium Low ________ _______ _______ Membership 0.086022 0.48387 0.43011

To assess the expected quality of life, compute crisp quality-of-life index values by defuzzifying the corresponding fuzzy state vectors.

${\mathit{Q}}_{{\alpha}_{\mathit{l}}}$ and ${\mathit{Q}}_{{\beta}_{\mathit{l}}}$ represent the following crisp index values, , respectively, for quality of life.

`yalpha_l = defuzz(yPeak,Qalpha_l,'centroid')`

yalpha_l = 1.5211

`ybeta_l = defuzz(yPeak,Qbeta_l,'centroid')`

ybeta_l = 1.6559

The post-surgery index value ${\mathit{y}}_{{\alpha}_{\mathit{l}}}$ is lower than the post-radiation index value ${\mathit{y}}_{{\beta}_{\mathit{l}}}$. Therefore, the radiation treatment provides a better expected long-term quality of life for the patient.

### Treatment Selection

The quantitative estimations obtained above show that the surgery is expected to deliver a better cancer control at the expense of possibly worse long-term health-related quality of life. The reverse is true for the radiation therapy.

Ultimately, the final decision on which treatment to use depends on the personal preference of the patient. For this example, represent the patient using weight factor $\theta \text{\hspace{0.17em}}$ in the range [0, 1]. A higher value of $\theta $ indicates a patient preference for disease control and a lower value indicates a preference for long-term health-related quality of life.

The following treatment preference functions provide a combined consideration of the two weighting factors.

$${\mathit{F}}_{\alpha \text{\hspace{0.17em}}}\left(\theta \text{\hspace{0.17em}}\right)=\theta {\mathit{x}}_{{\alpha}_{\mathit{c}}}+\left(1-\theta \right){\mathit{y}}_{{\alpha}_{\mathit{l}}}$$

$${\mathit{F}}_{\beta \text{\hspace{0.17em}}}\left(\theta \text{\hspace{0.17em}}\right)=\theta {\mathit{x}}_{{\beta}_{\mathit{c}}}+\left(1-\theta \right){\mathit{y}}_{{\beta}_{\mathit{l}}}$$

A higher value of ${\mathit{F}}_{\alpha}$ indicates patient preference for surgery and a higher value of ${\mathit{F}}_{\beta}$ indicates patient preference for radiation.

Plot the treatment preference functions for all values of $\theta $.

theta = 0:0.01:1; F_alpha = theta*xalpha_c + (1-theta)*yalpha_l; F_beta = theta*xbeta_c + (1-theta)*ybeta_l; plot(theta,F_alpha,theta,F_beta) title("Treatment Selection") xlabel("Patient Weighting Factor, theta") legend("Surgery Preference","Radiation Preference",... Location="northwest") grid on

In this case, for $\theta $ greater than about 0.25, surgery is the preferred choice of treatment.

### Online Supervised Learning of FDES

You can learn the event-transition matrices of an FDES online as new data becomes available. In the case of a clinical decision-making system, you can use the results from new patients to gradually improve the FDES model through supervised learning. Over time, the resulting model would cover a more diverse patient population, which can improve prediction accuracy for individual patients in the future.

This example demonstrates the learning process for a single patient.

Generally, an event transition matrix ${\alpha}^{\mathit{k}}$ at the ${\mathit{k}}^{\mathrm{th}}$ instant is updated with its previous value ${\alpha}^{\mathit{k}-1}$,the current pre-event state ${\mathit{Q}}^{\mathit{k}-1}$, and current expected post-event state ${\mathit{Q}}^{\mathit{k}}$ [3].

Let:

${\alpha}^{\mathit{k}}={\left[{\alpha}_{\mathrm{ij}}^{\mathit{k}}\right]}_{\mathit{N}\times \mathit{N}}$, where $\mathit{i},\mathit{j}=1,\cdots ,\mathit{N}$

$${\mathit{Q}}^{\mathit{k}-1}={\left[{\mu}_{\mathit{i}}^{\mathit{k}-1}\right]}_{\mathit{N}}$$

${\mathit{Q}}^{\mathit{k}}={\left[{\mu}_{\mathit{i}}^{\mathit{k}}\right]}_{\mathit{N}}$

Each element of the event matrix is learned as follows:

${\alpha}_{\mathrm{ij}}^{\mathit{k}}={\alpha}_{\mathrm{ij}}^{\mathit{k}-1}-\lambda {\mu}_{\mathit{i}}^{\mathit{k}-1}\left({\stackrel{\u02c6}{\mu}}_{\mathit{j}}^{\mathit{k}}-{\mu}_{\mathit{j}}^{\mathit{k}}\right){\delta}_{\mathrm{ij}}^{\mathit{k}}$

Here, $\lambda >0$ is a learning rate whose value is determined by the model.

${\stackrel{\u02c6}{\mathit{Q}}}^{\mathit{k}}={{\mathit{Q}}^{\mathit{k}-1}\circ {\alpha}^{\mathit{k}-1}=\left[{\stackrel{\u02c6}{\mu}}_{\mathit{i}}^{\mathit{k}}\right]}_{\mathit{N}}$ is an actual state at the ${\mathit{k}}^{\mathrm{th}}$ instant obtained from ${\alpha}^{\mathit{k}-1}$ and ${\mathit{Q}}^{\mathit{k}-1}$ using max-product fuzzy inference ($\circ $).

$${\delta}_{\mathrm{ij}}^{\mathit{k}}=\{\begin{array}{ll}1,& \mathrm{when}\text{\hspace{0.17em}}{\stackrel{\u02c6}{\mu}}_{\mathit{j}}^{\mathit{k}}={\mu}_{\mathit{i}}^{\mathit{k}-1}{\alpha}_{\mathrm{ij}}^{\mathit{k}-1}\\ 0,& \mathrm{otherwise}\end{array}$$

For this example, update the surgery event-transition matrix ${\alpha}_{\mathit{c}}\text{\hspace{0.17em}}$using the results for a single patient.

$$\begin{array}{l}{\alpha}^{\mathit{k}-1}={\alpha}_{\mathit{c}}\\ {\mathit{Q}}^{\mathit{k}-1}={\mathit{q}}_{\mathit{o},\mathit{c}}\\ {\stackrel{\u02c6}{\mathit{Q}}}^{\mathit{k}}={\mathit{Q}}_{{\alpha}_{\mathit{c}}}\end{array}$$

Suppose that the target state ${\mathit{Q}}^{\mathit{k}}$ corresponding to ${\mathit{q}}_{\mathit{o},\mathit{c}}$ is determined using a physical diagnosis after the treatment.

$${\mathit{Q}}^{\mathit{k}}=\left[\begin{array}{cccc}0.2& 0.6& 0.15& 0.1\end{array}\right]$$

Assume the patient represented by the pair $\left({\mathit{q}}_{\mathit{o},\mathit{c}},{\mathit{Q}}^{\mathit{k}}\right)$ is the only sample available for learning.

Iteratively update event matrix ${\alpha}^{\mathit{k}}$ with learning rate $\lambda =0.2$ for a preset root-mean-square-error (RMSE) goal of 0.02.

```
N = 4;
lambda = 0.2;
alphak_1 = alpha_c;
Qk_1 = qo_c;
Qhat = Qalpha_c;
Qk = [0.2 0.6 0.15 0.1];
alphak = zeros(N,N);
rmse = sqrt(mean((Qhat-Qk).^2));
fprintf("Initial RMSE = %g\n",rmse);
```

Initial RMSE = 0.089908

errorGoal = 0.02; iteration = 0; while rmse>errorGoal iteration = iteration + 1; for i = 1:N for j = 1:N alphak(i,j) = alphak_1(i,j)-lambda*Qk_1(i)*(Qhat(j)-Qk(j)); end end alphak_1 = alphak; Qhat = findNextState(Qk_1,alphak_1); rmse = sqrt(mean((Qhat-Qk).^2)); fprintf("Iteration %d: RMSE = %g\n",iteration,rmse); end

Iteration 1: RMSE = 0.0812763 Iteration 2: RMSE = 0.0736111 Iteration 3: RMSE = 0.0668027 Iteration 4: RMSE = 0.0607548 Iteration 5: RMSE = 0.055383 Iteration 6: RMSE = 0.0506125 Iteration 7: RMSE = 0.0463777 Iteration 8: RMSE = 0.0426206 Iteration 9: RMSE = 0.0392899 Iteration 10: RMSE = 0.03634 Iteration 11: RMSE = 0.0337306 Iteration 12: RMSE = 0.0314255 Iteration 13: RMSE = 0.0293927 Iteration 14: RMSE = 0.0276031 Iteration 15: RMSE = 0.0260309 Iteration 16: RMSE = 0.0246527 Iteration 17: RMSE = 0.0234472 Iteration 18: RMSE = 0.0223954 Iteration 19: RMSE = 0.02148 Iteration 20: RMSE = 0.0206853 Iteration 21: RMSE = 0.0199972

You can follow a similar approach for online supervised learning of other event transition matrices.

### References

Feng Lin and Hao Ying. “Modeling and Control of Fuzzy Discrete Event Systems.”

*IEEE Transactions on Systems, Man and Cybernetics, Part B (Cybernetics)*32, no. 4 (August 2002): 408–15. https://doi.org/10.1109/TSMCB.2002.1018761.Ying, H., F. Lin, R.D. Macarthur, J.A. Cohn, D.C. Barth-Jones, H. Ye, and L.R. Crane. “A Fuzzy Discrete Event System Approach to Determining Optimal HIV/AIDS Treatment Regimens.”

*IEEE Transactions on Information Technology in Biomedicine*10, no. 4 (October 2006): 663–76. https://doi.org/10.1109/TITB.2006.874200.Ying, Hao, and Feng Lin. “Online Self-Learning Fuzzy Discrete Event Systems.”

*IEEE Transactions on Fuzzy Systems*28, no. 9 (September 2020): 2185–94. https://doi.org/10.1109/TFUZZ.2019.2931254.

### Helper Functions

Calculate the next state using the current state and event, normalizing the next-state values.

function nextState = findNextState(currentState,event) nextState = zeros(size(currentState)); stateSum = 0; for col=1:size(event,2) stateValue = max(currentState.*event(:,col)'); nextState(col) = stateValue; stateSum = stateSum + stateValue; end if stateSum~=0 nextState = nextState/stateSum; end end

Display a fuzzy event matrix.

function showEventMatrix(eventMatrix,stateNames,varName) description = sprintf("Event matrix, %s",varName); showMatrix(eventMatrix,stateNames,stateNames,description) end

Display a fuzzy state vector.

function showStateVector(stateVector,stateNames,varName,label) description = sprintf("State vector, %s",varName); showMatrix(stateVector,label,stateNames,description) end

Display a matrix.

function showMatrix(mat,rowNames,colNames,description) vars = mat2cell(mat,size(mat,1),ones(1,size(mat,2))); t = table(vars{:},VariableNames=colNames,RowNames=rowNames); fprintf("%s:\n\n",description); disp(t) end