Re: Conversion to double from sym is not possible
- From: "Abdullah A" <abadee15@xxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 10:53:40 -0400
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
x =
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 :
[ 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
.
- References:
- Conversion to double from sym is not possible
- From: A. Abdullah
- Conversion to double from sym is not possible
- Prev by Date: Re: MATLAB help-using diff
- Next by Date: Re: MATLAB help-using diff
- Previous by thread: Re: Conversion to double from sym is not possible
- Next by thread: updating matrix after updating patch
- Index(es):
Relevant Pages
|