How to add the signals according to time?
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
- 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.
- 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 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!