How can I fix a solve error?
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
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
  Thomas Koelen
      
      
 2015년 4월 29일
				
      편집: Thomas Koelen
      
      
 2015년 4월 29일
  
			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.
답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

