The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: symbolic in FOR loop. not run...WHy??
Replies: 1   Last Post: Dec 31, 2012 12:48 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: symbolic in FOR loop. not run...WHy??
Posted: Dec 31, 2012 12:48 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Quynh Tram Nghuyen Thi" <> wrote in message
> Helloo all,
> I may put a question about symbolic & for loop. I AM USING FOR loop to
> construct functions as following:
> (M-FILE)
> syms x y
> for i=1:4
> N(i,1)=(x-1)*(y-1);N(i+4,1)=(x-5+i)*(y-2);


If N is a double array already, this will need to convert (x-1)*(y-1) into a
double precision value in order to store that value in an element of N.
However, since you haven't specified a value for x or y, it cannot perform
that conversion and so throws the error. Either specify NUMERIC values for x
and y in your script/function [so that (x-1)*(y-1) results in a numeric
value which can be converted to a double precision value] or initialize N
symbolically before running this loop so MATLAB doesn't need to convert the
symbolic (x-1)*(y-1) to perform the assignment.

N = sym(zeros(4, 4));

Steve Lord
To contact Technical Support use the Contact Us link on

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.