Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: symbolic in FOR loop. not run...WHy??
Posted:
Dec 31, 2012 12:48 AM


"Quynh Tram Nghuyen Thi" <lovelyeverything@yahoo.com.vn> wrote in message news:kb29gd$ltb$1@newscl01ah.mathworks.com... > Helloo all, > I may put a question about symbolic & for loop. I AM USING FOR loop to > construct functions as following: > > (MFILE) > syms x y > for i=1:4 > N(i,1)=(x1)*(y1);N(i+4,1)=(x5+i)*(y2);
*snip*
If N is a double array already, this will need to convert (x1)*(y1) 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 (x1)*(y1) 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 (x1)*(y1) to perform the assignment.
N = sym(zeros(4, 4));
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



