Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Matrix formed in for loop
Replies: 1   Last Post: Feb 27, 2013 11:50 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: Matrix formed in for loop
Posted: Feb 27, 2013 11:50 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.