Ramp a variable with 63 elements

I have a simulink variable that has 63 elements. I would like to ramp each element in the variable proportionally from 0 to the value of the variable.
For example
A = [22 17 39 ...]
B = [0 0 0 ...]
Sample time = Ts = 1e-6
B = Ramp A
Maybe I need a toolkit that has a premade ramp block that takes an input and sets upper and lower limits.
Thanks,
David

2 Commenti

To check:
Do you want B to start with 0 and proceed to 22 over a fixed time, with a timestep of 1e-6? And then B should start over from 0 and proceed to 17 over a fixed time, with a timestep of 1e-6? Then B should start at 0 and proceed to 39 over a fixed time, with a timestep of 1e-6 ?
Or do you want B to start with 0 and ramp to 22 over a fixed time, with a timestep of 1e-6, followed by ramping from 22 to 17 over a fixed time with a timestep of 1e-6, then ramping from 17 to 39 over a fixed time with a timestep of 1e-6 ?
Or do you want B to become a 2D array, in which the first colum ramps from 0 to 22, the second column ramps from 0 to 17, the third column ramps from 0 to 39, all over a fixed time, so the last row would be 22 17 39 ?
Thanks for the help. I am using Specialized Power System blocks. My sample rate Ts = 1e-6. I have 63 elements that represent harmonic currents. I need to ramp the value from 0 to its maximum. The picture below is what I am trying to do. Once the values have ramped from zero to their value, the signal needs to stay at its value until I am ready to ramp it to zero at a later time. The first element will have a frequency of 60 Hz, with a period of 1/60 = 16.666e-3 second. I would like the ramp to last at least three cycles of the slowest frequency; therefore 3*16.666-3 = 49.999e-3 seconds.

Accedi per commentare.

Risposte (2)

Walter Roberson
Walter Roberson il 24 Ago 2024

0 voti

First option:
Use a Simulink ramp block with a vector of slopes, and with the setting of "Interpret vector parameters as 1-D" set to on (on is the default.) You might need to combine it with if/elseif and a zero-order hold block and a ramp-down block in order to get the ramp-down effect.
Second option:
Use a MATLAB Function Block with Clock as the input. Have the MATLAB Function Block implement the ramp/hold/ramp-down behaviour.
If you do not need a smooth differentiable Ramp function, then use this math function:
where is the saturation value in the 63-element array S.
Note: The maximum saturation value in the array must be known.
S = [17, 22, 39]; % Saturation values
t = linspace(0, 0.1, 1001);
f = @(t) min(1, max(0, max(S)*t)); % Saturating Ramp function
for i = 1:numel(S)
plot(t, S(i)*f(t))
hold on
end
grid on, grid minor
xlabel('Time, t'), ylabel('f(t)')
title('Saturating Ramp function')

Prodotti

Release

R2024a

Richiesto:

il 23 Ago 2024

Risposto:

il 24 Ago 2024

Community Treasure Hunt

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

Start Hunting!

Translated by