Clear Filters
Clear Filters

How can I fix a solve error?

1 view (last 30 days)
Lorena Ortiz
Lorena Ortiz on 29 Apr 2015
Commented: Lorena Ortiz on 29 Apr 2015
I've done a program but I can't execute it because I keep getting this error:
??? Error using ==> char
Complex values cannot be converted to chars
Error in ==> sym.solve at 46
S{k} = char(varargin{k});
Error in ==> foro at 24
cf(i,j)=solve(PRe,c);
I need some help to fix the problem. Here is the program:
clear all
close all
s=input('Introduce s (1-40): ');
n=input('Introduce n (1-100): ');
af=zeros(1,s);
bf=zeros(s,n);
cf=zeros(s,n);
B=zeros(1,s);
C=zeros(1,s);
syms a b c;
F=6*a^3-10*b^2+c+i*(2*a+b+c);
Re=real(F)
Im=imag(F)
for i=1:s
af(i)=i;
a=af(i);
for j=1:n
bf(i,j)=j;
b=bf(i,j);
PRe(i,j)=subs(Re);
cf(i,j)=solve(PRe,c);
c=cf(i,j);
PImag(i,j)=subs(Im);
if PImag(i,j)==0
B(1,i)=bf(i,j);
C(1,i)=cf(i,j);
break;
else
bf(i,j)=bf(i,j);
end
j=j+1;
end
i=i+1;
end
disp('B is: ' )
B
Thank you!
  2 Comments
Thomas Koelen
Thomas Koelen on 29 Apr 2015
Edited: Thomas Koelen on 29 Apr 2015
I can't help you right now, all the symbolic toolboc auths are in use at my work at the moment, but what I can tell you is:
Don't use i as your start variable because it overwrites matlabs i,
don't do this: i=i+1; and j=j+1 you are using a for loop, your loop adds 1 every iteration by default.
Lorena Ortiz
Lorena Ortiz on 29 Apr 2015
Hi Thomas, I tried what you said but still gives me the same error..
Thank you anyway!

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!