Why this functions doesn't work on matlab coder
function [Rs] = Racineb(s)
imax=25;
emax=0.00001;
x=s;
if s<0
Rs='erreur';
disp('le paramètre entrée s doit être positif')
end
for i=1:imax
Rs=x-(x^2-s)/(2*x);
E=abs((Rs-x)/x);
x=Rs;
if E<emax
break
end
end
if E>emax
Rs='erreur';
disp('Le nombre de 25 itération a ete atteint sans avoir trouvé la solution')
end
It is saying that this assignment writes a 'double' value into a 'char' type. The problem is with Rs and x.
How can I resolve this problem? Thank you

 채택된 답변

Sean de Wolski
Sean de Wolski 2016년 10월 18일

0 개 추천

Don't convert Rs to a char!
Rs is a double here:
Rs=x-(x^2-s)/(2*x);
Here you convert it to a char.
Rs='erreur';
Use a different variable instead or set Rs to nan.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2016년 10월 18일

답변:

2016년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by