how to convert MatLab functions to RStudio?

0
tempo=Seq;   
conc=NCelTotais;
coef_ini = [MaxCT 1 2]; 
coef=[];
OPTIONS = optimset('MaxIter',1000,'TolFun',0.001,'TolX',0.01);
coef = fminsearch(@funcaoerro_sigmoide,coef_ini,OPTIONS);
A=coef(1);
B=coef(2);
C=coef(3);
y = A*sigmf(tempo, [B C]);
fNCelTotais=y;


where:
**funcaoerro_sigmoide**

function erro = funcao_sigmoide(coef);

global tempo conc;

A=coef(1);
B=coef(2);
C=coef(3);

y = A*sigmf(tempo, [B C]);
erro1 = (conc-y).^2;

erro=sum(erro1);
    
asked by anonymous 16.01.2018 / 00:03

2 answers

0

TL; DR:

You have to translate, seeing what one code does and implementing in the other language.

More details:

In fact, your question is not very clear, but assuming you need to translate the function you put up for , there is not much to do. Maybe there is someone who has something similar in R, but you still need to describe what the function does (it's the fit error of a function sigmoid ).

There is an R / MATLAB CRAN package , but it is just an interface to MatLab, which needs to be installed on the system . I do not know if it is compatible with RStudio.

    
16.01.2018 / 08:54
-1

I'll try to explain better! I have a set of experimental data that need to be adjusted by a theoretical curve (eg sigmoid) through least squares. In MatLab you have the main program and its corresponding function that calculates by least squares. main program 'time = Seq; conc = NCelTotais; coef_ini = [MaxCT 1 2]; coef = []; OPTIONS = optimset ('MaxIter', 1000, 'TolFun', 0.001, 'TolX', 0.01); coef = fminsearch (@funcaoerro_sigmoide, coef_ini, OPTIONS); A = coef (1); B = coef (2); C = coef (3); y = A * sigmf (time, [B C]); fnCelTotais = y; ' subroutine described as function

    
31.01.2018 / 16:29