Date: Feb 27, 2013 11:50 AM
Author: Steven Lord
Subject: Re: Matrix formed in for loop

"Lakshmi " <guesswho1705@yahoo.com> wrote in message

news:kgjj2k$6p0$1@newscl01ah.mathworks.com...

> Hi

>

> I am trying to generate a matrix in a for loop with it's elements as

> symbols rather than actual numbers. I want to later use this matrix in

> another loop where the symbols values are assigned but the values change

> with every loop.

> Initially I had tried putting the loop developing the matrix within the

> loop that gives the values, but it threw an error saying number of matrix

> elements should be definite.

>

> The problem I am having currently is when I execute this piece of code

> for cc1=1:4

> for cc2=1:4

> for cc3=1:4

> for cc4=1:4

> Tc(ac,1)=expand(T1(cc1))*(T2(cc2))*(T3(cc3))*(T4(cc4));

> ac=ac+1;

> end

> end

> end

> end

>

> where T1,2,3,4 are matrices with symbolic elements,

>

> I get this error

> ??? The following error occurred converting from sym to double:

> Error using ==> mupadmex

> Error in MuPAD command: DOUBLE cannot convert the input expression into a

> double array.

>

> If the input expression contains a symbolic variable, use the VPA function

> instead.

Preallocate Tc to be a _symbolic_ matrix not a numeric matrix.

Tc = sym(zeros(4^4, 1));

--

Steve Lord

slord@mathworks.com

To contact Technical Support use the Contact Us link on

http://www.mathworks.com