Filter löschen
Filter löschen

Is Simulink can call to a MATLAB Function, and the symbolic function and the 'subs' function can be included in the matlab function?

2 Ansichten (letzte 30 Tage)
I want to use the simulink to call to the Matlab Function block. And want to use symbolic function and 'subs' function in the m.file. and the simulink program and the code of the m.file was attached on
function [x,time]=Steffensentt(delta_dot0,x0) coder.extrinsic('subs','syms','num2str','global','str2num');
syms f;syms f2;syms f3;syms f4;syms f5;syms f6;syms f7;
syms y;syms z;
f1='0.5*0.463^2*';
f2=num2str(delta_dot0);
f3='^2+(1-0.621)*(3.4e3^2/x^2*log(';
f4=num2str(delta_dot0);
f5='*x/3.4e3+1)-3.4e3*';
f6=num2str(delta_dot0);
f7='/x)';
f=[f1,f2,f3,f4,f5,f6,f7];
if(nargin==2)
tol=1.0e-5;
end
time=0; err=0.1; x=x0;
while(err>tol)
x1=x;
y=subs(f,x1)+x1;
z=subs(f,y)+y;
x=x1-(y-x1)^2/(z-2*y+x1);
err=abs(x-x1);
time=time+1;
end
err
x
time;

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by