3

I want want to do some string calculation using Matlab, and then stored the value in an matrix.

For numerical study, I often predefined the dimensions in Matlab using zeros to create a 4*4 array.

a = zeros(4)

Now I want to do the same thing for the symbolic matrix. Obviously zeros didn't work at this time.

I tried to copy the official tutorial at this page http://www.mathworks.com/help/symbolic/sym.html

a = sym('0' ,4)  % error

Still didn't work.

Now I have do use the ugly code like this

a = sym('[0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0]');

Since I will use iterations, and dimension of the matrix grows every time. This method is not convenient.

Do you have any ideas? Thanks a lot!

0

2 Answers 2

4

Num = sym(Num) converts a number or a numeric matrix Num to symbolic form.

a=sym(zeros(4,4))
1
  • 2
    You could also do a = sym(zeros(4)) with the same effect.
    – nkjt
    Jan 31, 2014 at 16:09
0

Can't try but suspect that the variables get initialized as zero by default. For example when using

a = sym('a' ,[2 2])
3
  • Creates a Matrix, but does not initialise with zero.
    – Daniel
    Jan 31, 2014 at 16:14
  • @Daniel Then I will delete this soon, but could you tell me what it initializes with if its not zero? Jan 31, 2014 at 16:24
  • 4 unknown complex numbers, similar to the math expression a in C^4
    – Daniel
    Jan 31, 2014 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.