Message Boards Message Boards

0
|
5941 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Trying to produce some matrices, but getting syntax errors :(

Posted 9 years ago

Can anyone see what I'm doing wrong here?

I'm trying to make some matrices for finite element analysis and I'm getting these errors: Picture with errors

However when i try to make something similar with a more simple matrix, it works just fine: Matrix that works

Any help is greatly appreciated :)

POSTED BY: Anders Bredahl
6 Replies

Anders,

I am brand new to Mathematica (V10) so can't offer much help other than to say that defining kk as you are trying to do, in a brand new notebook with a freshly fired up kernel works fine for me.

POSTED BY: David Mackay

This evening I had the following error

Cannot be followed

which seemingly is meaningless. But I had used the escape key careless (to insert the \[Mu]). After reediting the extra-escape disappeared and the code became legal. Thereofore I'm afraid in your case some non-printable (and wrong) key strokes in connection with 2D-input caused the error.

POSTED BY: Udo Krause
Posted 9 years ago

Clearing the memory didn't help, but now I seem to get some different error messages?? enter image description here

POSTED BY: Anders Bredahl

Strange, this works here

In[20]:= (* http://community.wolfram.com/groups/-/m/t/352651 *)
Clear[a, iy, l, e, kk]
kk[a_, iy_, l_, e_] := 
 {{e a/l, 0, 0, -e a/l, 0, 0}, 
  {0, 12 e iy/l^3, 6 e iy/l^2, 0, -12 e iy/l^3, 6 e iy/l^2}, 
  {0, 6 e iy/l^2, 4 e iy/l, 0, -6 e iy/l^2, 2 e iy/l}, 
  {-e a/l, 0, 0, e a/l, 0, 0}, 
  {0, -12 e iy/l^3, 6 e iy/l^2 , 0, 12 e iy/l^3, -6 e iy/l^2}, 
  {0, 6 e iy/l^2, 2 e iy/l, 0, -6 e iy/l^2, 4 e iy/l}}

In[22]:= Dimensions[kk[Sequence @@ Range[4]]]
Out[22]= {6, 6}

In[23]:= kk[Sequence @@ Range[4]]
Out[23]= {{4/3, 0, 0, -(4/3), 0, 0}, {0, 32/9, 16/3, 0, -(32/9), 16/3}, 
          {0, 16/3, 32/3, 0, -(16/3), 16/3}, {-(4/3), 0, 0, 4/3, 0, 0},
          {0, -(32/9), 16/3, 0, 32/9, -(16/3)}, {0, 16/3, 16/3, 0, -(16/3), 32/3}}

In[25]:= N[MatrixExp[kk[Sequence @@ Range[4]]]]
Out[25]= {{7.69596, 0., 0., -6.69596, 0., 0.}, 
          {0., 1.3434*10^8, 1.18394*10^8, 0., -1.3434*10^8, 2.14073*10^8}, 
          {0., 2.01511*10^8, 1.77591*10^8, 0., -2.01511*10^8, 3.21109*10^8}, 
          {-6.69596, 0., 0., 7.69596, 0., 0.},
          {0., -2.8509*10^7, -2.51245*10^7, 0., 2.8509*10^7, -4.54298*10^7}, 
          {0., 2.01511*10^8, 1.77591*10^8, 0., -2.01511*10^8, 3.2111*10^8}}

things you could try

  • clear variables like the example does (has been already said earlier here)
  • start Mathematica new, open an new notebook and copy the above expression into it ...
  • do you use special contexts or do you enjoy some outrageous formatting rules or language settings in your operating system showing you other symbols in the FrontEnd than send to the kernel??
  • if it denies still to work, give FullForm[] a try to see what is send to the kernel ...
POSTED BY: Udo Krause

Have you tried to clear memory prior to running the first FEM matrix? It maybe that the second works because kkk has had no prior remembered definitions. Try after including the Clear statement before your definition for kk.

Clear["Global`*"]
POSTED BY: Isaac Abraham
Posted 9 years ago

Also mathematica seems to think there's something wrong with my brackets, but I can't see what it is either.

POSTED BY: Anders Bredahl
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