MATLAB Answers

Signal Simulink from / to Workspace

1 ビュー (過去 30 日間)
Rodrigo Vialle
Rodrigo Vialle 2021 年 5 月 25 日
コメント済み: Fangjun Jiang 2021 年 5 月 26 日
Hello, I have this variable called SigData in the workspace that I send to Simulink to the transfer fuction block
My problem is, if I change the cycle of the input to more than one:
I have the following error in Simulink:
clear all
Heart_Rate = 72; % Heart rate [beats/min]
Duty = 2/5; % Fraction of period occupied by systole
T = 60/Heart_Rate; % Heart period [s]
Time_Systole = Duty*T; % Time occupied by systole [s]
Time_Diastole = T - Time_Systole;
Max_Flow = 500; %[m^3/s] = 4.98 l/min
Number_Cycles = 1;
r = 0.05;
C = 1.0666;
R = 0.9;
L = 0.0051;
Q = zeros(Number_Cycles * (int16 (round(T,3)/0.001)), 1);
aux=1;
for i = 1:Number_Cycles
for t = 0.001:0.001:round(T,3)
if (t <= Time_Systole)
SigData(aux,1) = t;
Q(aux) = Max_Flow*(sin((pi*t)/Time_Systole))^2;
SigData(aux,2)= Q(aux);
end
if (t > Time_Systole)
SigData(aux,1)=t;
Q(aux,2)=0;
SigData(aux,2)=Q(aux);
end
aux=aux+1;
end
end

採用された回答

Fangjun Jiang
Fangjun Jiang 2021 年 5 月 25 日
The data in the first column of SigData is the time (or time step) info. It must be incremental (or non-descreasing).
Based on your code, when there is more than one cycle, the time step is constructed as 0.001 to 3, and then 0.001 to 3 again and then 0.001 to 3 again.
Change this line
SigData(aux,1) = t
to SigData(aux,1) = t+(i-1)*round(T,3)
  2 件のコメント
Fangjun Jiang
Fangjun Jiang 2021 年 5 月 26 日
Use "To Workspace" block

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by