Signal Simulink from / to Workspace
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Rodrigo Vialle
il 25 Mag 2021
Commentato: Fangjun Jiang
il 26 Mag 2021
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
0 Commenti
Risposta accettata
Fangjun Jiang
il 25 Mag 2021
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Sources in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!