How can I fix a solve error?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Thomas Koelen
le 29 Avr 2015
Modifié(e) : Thomas Koelen
le 29 Avr 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!