2012-04-14 39 views
0

注意:這是我第一次使用MATLAB S函數,而且我只用了少量的Simulink。s函數直接饋通

當我嘗試在S函數inp中使用我的輸入變量時,他們返回NaN標誌3。系統的輸入是三個簡單的統一步驟功能,通過總線創建者連接到系統。當試圖模擬系統時,我收到一條錯誤信息 - 我只通過在inp上進行測試打印而發現它們是NaN。有任何想法嗎?


詳情:
我模擬賽格威作爲一類項目。我在Simulink中將執行器(直流電機)和設備(Segway本身)作爲單獨的S功能塊進行仿真。電機需要三個輸入:一個電壓,Segway的速度,以及相對於其俯仰軸的角速度Segway(由於反電動勢)。輸出是電樞電流。

這是一個簡單的線性非差分系統。出於這個原因,沒有國家。唯一完成的計算是從輸入到輸出的饋通。代碼如下:

function [sys,X0]=nl_pend(time,state,inp,FLAG,ICs); 
% actuator parameters: 
% R_m: motor armature resistance 
% K_b: motor back emf constant 
% K_t: motor torque constant 
% r: radius of the wheel 
global R_m K_b K_t r; 

if FLAG == 0, % initialize system parameters and states 
% Call file that initializes parameters 
    segway_dcmotor_pars; 
% This system has: 
% 0 states (theta,thetatheta_dot), 
% 3 input (v,x_dot,theta_dot), 
% 1 outputs (i) 
nx = 0; % # of states 
nu = 3; % # of inputs 
ny = 1; % # of outputs 
sys = [nx; 0; ny; nu; 0; 0]; 
% Initial Conditions (will be passed as and argument) 
X0 = ICs; 
elseif FLAG == 1, % states derivatives 
    %blank 
elseif FLAG == 3, % system outputs 
    %inp(1) = motor voltage 
    %inp(2) = segway velocity 
    %inp(3) = segway pitch angular velocity 
    display(inp); 
    y(1) = (1/R_m)*inp(1) - (K_b/(r*R_m))*inp(2) + (K_b/R_m)*inp(3); 
    sys = y; 
else, 
    sys = []; 
end 
+0

嘛。我改變了它,以便不是沒有狀態,系統有一個單一的狀態q,它是電樞中的電荷。 由於這是一個解決方案,而不是一個答案,我會留下任何想法的問題,爲什麼第一種方法不起作用。 – Ataraxia 2012-04-14 16:25:02

回答

1

至於你提到的,我已經找到了解決辦法是直接饋通,所以你必須設置

sys(6)=1 in flag==0...