matlabfunctionmathsimulink

how to make this function periodic in MATLAB?


I have wrote this code in MATLAB editor and want this function to be periodic (period = 0.8s)

HR=75;

E_max=2.0;

E_min=0.06;

t_c=60/HR;

T_max=0.2+0.15*t_c;

t=0:0.0001:t_c;

t_n=t/T_max;

E_n=1.55*(((t_n/0.7).^1.9)./(1+(t_n/0.7).^1.9)).*(1./(1+(t_n/1.17).^21.9));

E=(E_max-E_min)*E_n+E_min;

plot(t,E)

I want to use the function in simulink as a voltage source. so i do not need a point but the whole function. so I need a function that takes the overall time (for example 20 secs) and gives the output CONTINUSELY (like a Sin function).

the function and it's shape is: http://tinypic.com/r/2641a1s/8


Solution

  • Create your data in the MATLAB base workspace by running your code in MATLAB before running your Simulink model. Then use the Repeating Sequence Block. Use your variable t as the Time Values and E as the Output Values. You'll also need to make sure that the maximum step size that the solver takes is min(diff(t)), which in the case of your data is 0.0001.

    enter image description here