logo资料库

matlab截取一段信号的代码.docx

第1页 / 共2页
第2页 / 共2页
资料共2页,全文预览结束
有两种方法: 一种,是直接在输入数据里面截取所要的部分的信号数据; 二种,是使用 xlim 函数在图形中限定所要信号的范围。 我想把信号分成一个个的小段,但是我现在写的这个程序只能截掉最前面的 1/5,后面的我 想同样按 1/5 分成四份,但是代码不会写了,那位高手帮帮忙吧!谢谢 代码: clear; clc; f0=10000; %用来模拟 模拟信号的 数字信号的采样频率 fs<
subplot(5,1,2);plot([101:200],s(101:200));axis([1 N min(s) max(s)]);grid on; subplot(5,1,3);plot([201:300],s(201:300));axis([1 N min(s) max(s)]);grid on; subplot(5,1,4);plot([301:400],s(301:400));axis([1 N min(s) max(s)]);grid on; subplot(5,1,5);plot([401:500],s(401:500));axis([1 N min(s) max(s)]);grid on; figure t=zeros(1,N/5); for i=1:num t=t+sin(f(i)*2*pi*(1:N/5)/f0+pi/2); end subplot(2,2,1);plot(t);axis([1 N min(s) max(s)]);grid on; t=zeros(1,N/5); for i=1:num t=t+sin(f(i)*2*pi*((N/5+1):(2*N/5))/f0+pi/2); end subplot(2,2,2);plot((N/5+1):(2*N/5),t);axis([1 N min(s) max(s)]);grid on; t=zeros(1,N/5); for i=1:num t=t+sin(f(i)*2*pi*((2*N/5+1):(3*N/5))/f0+pi/2); end subplot(2,2,3);plot((2*N/5+1):(3*N/5),t);axis([1 N min(s) max(s)]);grid on; t=zeros(1,N/5); for i=1:num t=t+sin(f(i)*2*pi*((3*N/5+1):(4*N/5))/f0+pi/2); end subplot(2,2,4);plot((3*N/5+1):(4*N/5),t);axis([1 N min(s) max(s)]);grid on; data0=rand(1,9999); %脑电信号原始数据 tm=0.02; %采样时间间隔 t=1:tm:10; %取时间 1-10 秒 data=data0(1:(10-1)/tm+1); %1-10 秒的数据 plot(t,data); xlabel('时间(秒)'),ylabel('脑波电压'),title('1-10s 脑电图波');
分享到:
收藏