change between two values with time dependent

2 次查看(过去 30 天)
Hi, I need a signal like sawtooth.
my primary equation is value_max=value_min+((value_max-value_min)/T)*t
t is the clock
T is signal changing time
signal starts with minumum value, then increases until reach maximum value at T.
After that immediately decrease minumum value then start again.
loop cont. with T 2T 3T...

回答(1 个)

Ayush
Ayush 2024-7-8
Hi,
To plot the sawtooth-like signal as per the parameters you have defined, you need to create a time vector to simulate the whole signal. The maximum and minimum values defined will decide the amplitude of the signal. The main calculation will be done using the equation you have provided. For better understanding refer to the example code below:
% Parameters
value_min = 0; % Minimum value of the signal
value_max = 1; % Maximum value of the signal
T = 10; % Signal changing time
t_total = 50; % Total time for the signal
% Time vector
t = 0:0.01:t_total; % Time from 0 to t_total with a step of 0.01
% Sawtooth signal calculation
signal = value_min + ((value_max - value_min) / T) * mod(t, T);
% Plotting the signal
figure;
plot(t, signal);
title('Sawtooth Signal');
xlabel('Time (s)');
ylabel('Signal Value');
grid on;

类别

Help CenterFile Exchange 中查找有关 Clocks and Timers 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by