Effacer les filtres
Effacer les filtres

How can I fix a solve error?

1 vue (au cours des 30 derniers jours)
Lorena Ortiz
Lorena Ortiz le 29 Avr 2015
Commenté : Lorena Ortiz le 29 Avr 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 commentaires
Thomas Koelen
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.
Lorena Ortiz
Lorena Ortiz le 29 Avr 2015
Hi Thomas, I tried what you said but still gives me the same error..
Thank you anyway!

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by