Clear Filters
Clear Filters

change between two values with time dependent

2 views (last 30 days)
tcagdas
tcagdas on 25 May 2021
Answered: Ayush on 8 Jul 2024
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...

Answers (1)

Ayush
Ayush on 8 Jul 2024
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;

Tags

Community Treasure Hunt

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

Start Hunting!