Re: Conversion to double from sym is not possible



Steven Lord wrote:



"A. Abdullah" <abadee15@xxxxxxxxxxx> wrote in message
news:ef3b87d.-1@xxxxxxxxxxxxxxxxxxxxxxxxxx
Hi.....I tried to run this code to get two elements of a matrix
:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tempL = UC{1,4}; %we will be working on one cell at the time
syms x y
Eq1 = tempL(:,1)'*[tempL(1:6,3);x;y]
Eq2 = tempL(:,2)'*[tempL(1:6,3);x;y]
[x,y] = solve(Eq1,Eq2)
tempL(7,3) = x
tempL(8,3) = y
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I got this error message :

??? Conversion to double from sym is not possible.

Error in ==> test at 28
tempL(7,3) = x
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
then I tried to cast the x and y to double:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tempL = UC{1,4}; %we will be working on one cell at the time
syms x y
Eq1 = tempL(:,1)'*[tempL(1:6,3);x;y]
Eq2 = tempL(:,2)'*[tempL(1:6,3);x;y]
[x,y] = solve(Eq1,Eq2)
tempL(7,3) = double(x)
tempL(8,3) = double(y)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I got this error message :

??? Error using ==> str2num
Requires string or character array input.

Error in ==> sym.double at 17
X = str2num(map2mat(char(maple('evalf',S(:),d))));

Error in ==> test at 28
tempL(7,3) = double(x)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can anyone help me to solve this ?

Either x or y contains a symbolic variable -- you can't convert
something
like '6*x' into a double. Either convert tempL into an array of
sym objects
or substitute values into x and y before calling DOUBLE on them to
remove
all symbolic variables from them.

--
Steve Lord
slord@xxxxxxxxxxxxx


When I run the code :
x =

[ empty sym ]

y =

[]
because in my case there is no answer for this equation. what I want
to do now is to but if statment so when there is no answer I will but
x=0 and y=o how I should do that I tried this but I want to know if
there is better answer:
if size(y,1) == 0
disp('yes')
tempL(7,3) = 0.0
tempL(8,3) = 0.0
else
disp('no')
tempL(7,3) = x
tempL(8,3) = y

end
.



Relevant Pages

  • Re: delete command weirdness
    ... another function *with the exact same behavior* and no side effects. ... it does a lot more CONSing while building that return value. ... can modify the place defined by sym in both the case ... a special variable (the value cell of the symbol sym). ...
    (comp.lang.lisp)
  • Re: Stylistic question on control transfer (return vs. throw)
    ... begin a "scope" and retain the location. ... can be handled through property lists. ... (dolist (sym list-of-syms) ... (loop for cell = list-of-syms then (cdr cell) ...
    (comp.lang.lisp)
  • Re: lambda-returning defmacro, capture
    ... So you're right that using sym to access in the ... that fact can be detected by the function boundp. ... contained in the value cell of a bound symbol is the value of the ... Operations on a symbol's value cell and function cell are sometimes ...
    (comp.lang.lisp)
  • Re: lambda-returning defmacro, capture
    ... So you're right that using sym to access in the ... And global variables are either dynamic variables or ... Operations on a symbol's value cell and function cell are sometimes ... So evaluating sym in the global environment accesses the dynamic ...
    (comp.lang.lisp)