필터 지우기
필터 지우기

How to add the signals according to time?

조회 수: 3 (최근 30일)
Reji G
Reji G 2022년 4월 21일
댓글: Mathieu NOE 2022년 4월 21일
Hello,
  1. I want to add the 3 decaying exponential sinusoids according to the timwe in one graph. I used hold on & hold off. But that is not the correct way.
  2. I want the pattern(1 complete cycle(combination of 3 exp signals)) to be repetitive.
clc;
close all;
clear all;
t=0:0.001:0.3;
a=-7.4*exp(-t/0.01).*sin(2*pi*(10)*t);
t1=0.3:0.001:0.4;
b=10^7*exp(-t1/0.02).*sin(2*pi*(10)*t1);
b1=flip(b);
t2=0.4:0.001:0.75;
c=-8.5^10*exp(-t2/0.02).*sin(2*pi*(10)*t2);
c1=flip(c);
t3=0:0.001:0.1;
d=sin(2*pi*50*t3);
figure(1)
plot(t/38,a,'b');
hold on
plot(t1/38,b1,'b');
hold on
plot(t2/38,c1,'b');
hold on
plot(t3,d);
hold off
  댓글 수: 2
KSSV
KSSV 2022년 4월 21일
What you are expecting?
Reji G
Reji G 2022년 4월 21일
편집: Reji G 2022년 4월 21일
In one x axis, from 0 to 0.3 seconds, signal 'a' should be plotted. In the same axis, from 0.3 to 0.4 signal b1 should be plotted. From 0.4 to 0.75 signal c1 should be plotted.
After 0.75 second the entire plot should repeat.

댓글을 달려면 로그인하십시오.

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 4월 21일
편집: Mathieu NOE 2022년 4월 21일
hello
try this (i made a few mods , see the comments)
clc;
close all;
clear all;
% In one x axis, from 0 to 0.3 seconds, signal 'a' should be plotted.
% In the same axis, from 0.3 to 0.4 signal b1 should be plotted.
% From 0.4 to 0.75 signal c1 should be plotted.
% After 0.75 second the entire plot should repeat.
dt = 0.001;
t1=0:dt:0.3-dt; % remove one sample at the end ( dt) to avoid duplicate with next segment first point
a=-7.4*exp(-t1/0.01).*sin(2*pi*(10)*t1);
t2=0.3:dt:0.4-dt; % remove one sample at the end ( dt) to avoid duplicate with next segment first point
b=10^7*exp(-t2/0.02).*sin(2*pi*(10)*t2);
b1=flip(b);
t3=0.4:dt:0.75;
c= + 8.5^10*exp(-t3/0.02).*sin(2*pi*(10)*t3); % changed sign from - to + here because it looked weird to me
c1=flip(c);
t=[t1 t2 t3];
y = [a b1 c1];
figure(1)
plot(t/38,y,'b');
% create repetitions of the signal
rep = 10; % repetitions
y_rep = repmat(y,[1 rep]);
t_rep = (0:numel(y_rep)-1)*dt;
figure(2)
plot(t_rep/38,y_rep,'b');
  댓글 수: 2
Reji G
Reji G 2022년 4월 21일
Thanks a lot...... Have a great day !!
Mathieu NOE
Mathieu NOE 2022년 4월 21일
as always , my pleasure !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by