From: "Steven_Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: symbolic in FOR loop. not run...WHy??
Date: Mon, 31 Dec 2012 00:48:22 -0500
Organization: MathWorks
Lines: 32
Message-ID: <kbr8v6$d3v$>
References: <kb29gd$ltb$>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1356932902 13439 (31 Dec 2012 05:48:22 GMT)
NNTP-Posting-Date: Mon, 31 Dec 2012 05:48:22 +0000 (UTC)
In-Reply-To: <kb29gd$ltb$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:785664

"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