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);
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);
if (t > Time_Systole)

채택된 답변

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