Matlab 绘制不同频率的信号

Matlab 绘制不同频率的信号,matlab,Matlab,我需要在matlab上绘制一个简单的x(t)函数,在特定时间后改变其频率: x(t)=t=1时的cos(2pi*2hz*t) 我在函数上使用了一个简单的IF语句,但似乎我必须使用一些现有的matlab函数来实现同样的功能。任何帮助都将不胜感激。这很简单: t1=0:0.01:1; t2=1:0.01:2; x1=cos(2*pi*2*t1); x2=cos(2*pi*5*t2); hold on plot(t1,x1,'b') plot(t2,x2,'b') 编辑:正如@Dan所建议的,

我需要在matlab上绘制一个简单的x(t)函数,在特定时间后改变其频率:

x(t)=t=1时的cos(2pi*2hz*t)

我在函数上使用了一个简单的IF语句,但似乎我必须使用一些现有的matlab函数来实现同样的功能。任何帮助都将不胜感激。

这很简单:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

hold on
plot(t1,x1,'b')
plot(t2,x2,'b')

编辑:正如@Dan所建议的,如果你想让整个信号都在一个变量中,这样你就可以用它做一些科学研究,你也可以做:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

x=[x1 x2];
t=[t1 t2];


plot(t,x)
就这么简单:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

hold on
plot(t1,x1,'b')
plot(t2,x2,'b')

编辑:正如@Dan所建议的,如果你想让整个信号都在一个变量中,这样你就可以用它做一些科学研究,你也可以做:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

x=[x1 x2];
t=[t1 t2];


plot(t,x)
就这么简单:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

hold on
plot(t1,x1,'b')
plot(t2,x2,'b')

编辑:正如@Dan所建议的,如果你想让整个信号都在一个变量中,这样你就可以用它做一些科学研究,你也可以做:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

x=[x1 x2];
t=[t1 t2];


plot(t,x)
就这么简单:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

hold on
plot(t1,x1,'b')
plot(t2,x2,'b')

编辑:正如@Dan所建议的,如果你想让整个信号都在一个变量中,这样你就可以用它做一些科学研究,你也可以做:

t1=0:0.01:1;
t2=1:0.01:2;

x1=cos(2*pi*2*t1);
x2=cos(2*pi*5*t2);

x=[x1 x2];
t=[t1 t2];


plot(t,x)

我建议将串联作为
hold on
so
t=[t1,t2]
x=[x1,x2]
的替代方案,然后只
plot(t,x)
我建议将串联作为
hold on
so
t=[t1,t2]
x=[x1,x2]
的替代方案,然后只
plot(t,x)
我建议将连接作为
hold on
的替代方案,因此
t=[t1,t2]
x=[x1,x2]
然后只
plot(t,x)
我建议将连接作为
hold on
so
t=[t1,t2]
x=[x1,x2]
的替代方案,然后只
plot(t,x)