Message Boards Message Boards

0
|
2560 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Numerical Matrix Entries are mathematical expressions instead

Posted 5 years ago

I am using an old Mathematica controls notebook for some present problems. When I generate the state space model my A matrix now has some entries that are expressions instead of numbers. For example, one entry is -6249.8 (-0.0012229 - 3.20374x10^-11. The matrix was first derived symbolically, then numerical values were assigned. I tried manipulating the values. I have searched in Mathematica Help as well as online, but haven't found anything yet.

The code used to work when first written. Now, the state space response won't compute. The notebook file is attached.

Attachments:
7 Replies
Posted 5 years ago

Richard,

I just remembered that I commented on a similar issue on MSE a couple of months ago. The touch bar on the Mac can insert such sequences into the notebook. You should report this issue to WRI.

POSTED BY: Rohit Namjoshi

Thanks, Rohit. I wonder where they came from, and I wonder why writing the offending expression differently solved the problem.

Posted 5 years ago

Hi Richard,

If you copy one of the odd expressions in the matrix A and paste it into a text editor or into this answer form you will see that there is an odd character sequence at the end \.10

-6249.804693603325` (-0.0012229040441303532` - 3.203739988383671`*^-11 \.10)

that is what is preventing the expression from being evaluated. It is the "funny character" that Daniel referred to in the definition of Gkp4j0. It is rendered as a space in the notebook at the end of the definition, so it is not obvious. If you delete it, save the notebook, restart the kernel and evaluate, matrix A no longer has those odd expressions.

(0  0    0  0    0  0    0  1    0  0    0  0    0  0
0   0 0   0 0   0 0   0 1   0 0   0 0   0
0   0 0   0 0   0 0   0 0   1 0   0 0   0
0   0 0   0 0   0 0   0 0   0 1   0 0   0
0   0 0   0 0   0 0   0 0   0 0   1 0   0
0   0 0   0 0   0 0   0 0   0 0   0 1   0
0   0 0   0 0   0 0   0 0   0 0   0 0   1
-0.043046   7.64291   22.9287   38.2146   53.5004   68.7862   84.072    -0.0549892 0   0 0   0 0   0
-0.0000185048   -0.263621 -0.542812   -0.855948 -1.21272    -1.55219   -1.90131  0.00124263   0 0   0 0   0 0
-6.16827*10^-6  -0.0822449   -0.552241 -0.442067   -0.354635 -0.542812   -0.618047 0.000414211 0   0 0   0 0   0
-3.70096*10^-6  -0.0269271   -0.25784  -1.12948 -0.614954   -0.197584 -0.43756    0.000248527    0  0    0  0    0  0
-2.64354*10^-6  -0.0284048   -0.0256587    -0.496523  -1.99534 -0.902137   -0.0707305    0.000177519    0  0    0  0    0  0
-2.05609*10^-6  -0.0169696   -0.0822449    0.0173475  -0.81441 -3.14982    -1.28589   0.00013807    0  0    0  0    0  0
-1.68225*10^-6  -0.0171755   -0.031871 -0.136097   0.0907671 -1.21611    -4.59291   0.000112967   0 0   0 0   0 0
)
POSTED BY: Rohit Namjoshi

I found and fixed an offending expression, but it is not obvious why it is offensive. Attached is a notebook file with the particulars. The expressions in the file are from the original one I posted. I tried different ways to express the problem expression. I finally found a way that fixed the problem. I would like to know why it worked.

I guess it would be a numeric matrix, except it isn't. I suspect there are two issues in play. One is that Gkp4j0 appears to have a funny character in the definition. The other is that My4jz4j has symbolic parts inside it (I mean things like My4jz4j[[1]]). I would suspect something got corrupted somewhere.

Best I can suggest is to go over the computations line by line to determine what's going astray.

POSTED BY: Daniel Lichtblau

This notebook was generated a couple months ago, at which time it worked correctly. I have tried to rerun a duplicate of it in hopes of changing a few parameters. I have checked with the original file to make sure the symbolic and numeric values have not changed. I didn't know how to force the numeric expressions in the matrix to evaluate to a single number. I tried commands like Simplify and FullSimplify. I searched for a possible cause in the documentation but haven't found anything.

I am sure it is a simple thing to fix, but I am unaware what to try.

BTW, what term is appropriate for the matrix? It is a symbolic matrix with numerical values substituted for the variables.

It's not a numerical matrix. What have you tried thus far to debug this notebook?

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract