필터 지우기
필터 지우기

converting M-file into a block function in simulink-2

조회 수: 1 (최근 30일)
dong van duc
dong van duc 2012년 8월 23일
I use a block "Level-2 M-file S-Function", M-file name = duong_truyen, I get a error: "Eroor due to multiple causes --> Too many input arguments.-->Error evaluating the initialization for M-S-Function 'duong_truyen'.Too many input arguments.The following is the MATLAB call stack (file names and line numbers) that produced this error:"
function [] = duong_truyen()
%--------------------------------
open('demo_layout.fig');
set(gcf,'name','Duong Truyen');
set(gcf,'NumberTitle','off');
%--------------------------------
% Lay vi tri truc toa do
placeHolderName = 'wrapAx';
thisAx = findobj('Tag',placeHolderName);
thisPos = get(thisAx,'position'); % lay vi tri cua thisAx
delete(thisAx);
%--------------------------------
wrapDial = dial('refVal',0,... % Val_ diemef
'refOrientation',90*pi/180,... % Orientation _ su dinh huong
'valRangePerRotation',360, ... % pham vi quay
'Min',0,... % nho nhat
'Max',359,... % lon nhat
'doWrap',1,... % wrap _ bao phu
'Value',0,... % gia tri
'Position',thisPos,... % vi tri = thisPos
'VerticalAlignment','bottom',... % duowng thang dung = day, phan
'Tag','wrapDial',... % Tag = wrapDial
'CallBack',@wrap_cb,... % goi ham "wrap_cb"
'titleStr','Keo kim quay',... % chuoi dau de (tit) = 'Wrapping' on
'titlePos','top',... % vi tri tit = dinh
'tickVals', [0 90 180 270],... % gia tri duowng tick
'tickStrs',{'N' 'E' 'S' 'W'}); % chuoi ghi o duowng tick
%--------------------------------
% Thiet lap mau.
faceColour = get(wrapDial.panelHndl,'facecolor'); set(findobj('Tag','wrapText'),'BackgroundColor',faceColour,'ForegroundColor','r');
set(findobj('Tag','wrapText'),'string','0');
%--------------------------------
% Co lai kich thuoc mat dong ho.
set(wrapDial,'dialRadius',0.55);
%--------------------------------
% Lam kim quay tuy bien.
x = [0 .55 .4 NaN .55 .4];
y = [0 0 .14 NaN 0 -.14];
set(wrapDial.linePointerHndl,'xdata',x,'ydata',y);
set(wrapDial.linePointerHndl,'color','r');
%--------------------------------
% Di chuyen ticklabel roi xa mat dong ho.
set(wrapDial,'tickLabelRadius',0.69);
%--------------------------------
% Thay doi font ticklabel.
set(wrapDial.tickLabelHndls,'fontname','Courier');
set(wrapDial.tickLabelHndls,'fontWeight','Bold');
set(wrapDial.tickLabelHndls,'fontSize',16);
%--------------------------------
%--------------------------------
function [] = wrap_cb()
% wrap_cb.m--Callback for "wrap" dial.
%--------------------------------------
wrapDial = dial.find_dial('wrapDial','-1');
dialVal = round(get(wrapDial,'Value'));
set(findobj('Tag','wrapText'),'string',sprintf('%d',dialVal));

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 8월 23일
You have not written an S-function, but just a MATLAB function in a format that Simulink will not understand. Please go through the documentation for MATLAB S-functions and look at some of the demos to understand how to right S-functions.
  댓글 수: 3
dong van duc
dong van duc 2012년 8월 24일
with my code, how do I could turn into a block in the "simulink"
Kaustubha Govind
Kaustubha Govind 2012년 8월 24일
duc1 duc2: Sorry, I'm really having trouble figuring how to answer better to help you understand. I've pointed you to the right documentation, but it's not clear whether you've been reading any of it because you've been asking the exact same question over and over again.

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by