필터 지우기
필터 지우기

function handle to matlab system / function file using code

조회 수: 2 (최근 30일)
rupprechtt
rupprechtt 2019년 9월 17일
답변: rupprechtt 2019년 9월 17일
Hi all,
I want to use a Matlab System or Matlab Function block in Simulink with one single equation.
After some calculations during simulink init, I obtain a function handle T = @(phi,phi_d,phi_dd). I now want to "copy" this function 'automatically' (i.e. using code) to the Matlab System file.
I realy need the automated soultion, but I have no idea how to change or generate m-files using code.
thanks for your help!
  댓글 수: 1
rupprechtt
rupprechtt 2019년 9월 17일
INFO - just in case it is easier to insert a string to the m-file - I obtain the function handle using
T = str2func(strcat('@(phi,phi_d,phi_dd ',func_str))

댓글을 달려면 로그인하십시오.

채택된 답변

rupprechtt
rupprechtt 2019년 9월 17일
solved myself:
line1 = 'functionhead'
line2 = strcat(' T = ',func_str,';');
line3 = 'end'
Fid = fopen('filename.m','w');
fprintf(Fid, '%s\n\n%s\n\n%s', line1,line2,line3),
fclose(Fid);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by