clear all close all rscom1=serial('COM1','BaudRate',19200,'DataBits',8,'Parity','none','StopBits',2); fopen(rscom1); figure(1) set(1,'doublebuffer','on'); try tic; while(1) accl=zeros(3,1000); aglvel=zeros(3,1000); agl=zeros(3,1000); timedat=(1:1000); for i=1:1000 a=gyroj(rscom1); timedat(1,i)=toc; accl(:,i)=a(1:3)'; aglvel(:,i)=a(4:6)'; agl(:,i)=a(7:9)'; %fprintf('%4.2f %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f\n ',a(1:3),sqrt(sum(a(1:3).^2)),a(7:9)); subplot(2,2,1);plot3([a(1) 0],[a(2) 0],[a(3) 0],'linewidth',5); grid;axis([-1.5 1.5 -1.5 1.5 -1.5 1.5]); subplot(2,2,2);plot(timedat(1,1:i),accl(:,1:i)); title('Acceleration');ylabel('G');xlabel('time[sec]'); subplot(2,2,3);plot(timedat(1,1:i),aglvel(:,1:i)); title('Angler velocity');ylabel('deg/sec');xlabel('time[sec]'); subplot(2,2,4);plot(timedat(1,1:i),agl(:,1:i)); title('Angle');ylabel('deg');xlabel('time[sec]'); drawnow; end end catch fclose(rscom1); delete(rscom1); clear rscom1; end