フィルターのクリア

How can I fix a solve error?

1 回表示 (過去 30 日間)
Lorena Ortiz
Lorena Ortiz 2015 年 4 月 29 日
コメント済み: Lorena Ortiz 2015 年 4 月 29 日
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
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.
Lorena Ortiz
Lorena Ortiz 2015 年 4 月 29 日
Hi Thomas, I tried what you said but still gives me the same error..
Thank you anyway!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by