フィルターのクリア

How to create a continuous cosine from different ''slices''

1 回表示 (過去 30 日間)
Sebastian Ciuban
Sebastian Ciuban 2016 年 12 月 18 日
コメント済み: Sebastian Ciuban 2016 年 12 月 18 日
Greetings,
I am trying to obtain a plot where I would like to represent a cosine function made from different time vectors. Here is the code I am using in order to make myself clear:
% Define the frequencies
fs = 1; % Hz
f1 = 1; % Hz
f2 = 2; % Hz
% Define the time vectors for 2 slices
time1= (1:0.1:20)*1/fs; % slice1
time2 = (20:0.1:40); % slice2
% Compute the cosine functions
cos1 = cos(2*pi*f1*time1);
cos2 = cos(2*pi*f2*time2);
Now, I do not know how to obtain a single continuous cosine in a plot. Normally, cos2 should begin where cos1 end. If I plot cos1 and cos2 on the same graph I will obtain 2 overlaped shifted cosines.
How can I make a plot where cos2 is 'glued' to cos1 obtaining a single cosine function which has two different frequencies and also assuring the continuation of time?
Any advice will be very appreciated.

採用された回答

the cyclist
the cyclist 2016 年 12 月 18 日
plot([time1 time2],[cos1 cos2])

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Function Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by