close all clear cd D:\data\ files = dir("*.txt*"); %%t = datetime(Y,M,D,H,MI,S,MS); % figure(1); time = 1:1:64000; PeriodIntegrate = 2; %pontInOneFqChange = 86; pontInOneFqChange = 86; global startPointTime; global height; height = 60; global timePoint; timePoint = 100; global update ; update =0; FQend = 512; % % for i=1:1:size(files,1) % A = readmatrix(files(i).name); %time = 1:1:size(A); % plot(time,A(time)), hold on; % end % hold off; old_size = size(files,1); SizeFirst = size (readmatrix(files(1).name),1); time = 1:1:size(readmatrix(files(1).name)); %figure (2); k = 1; oldA = 0; SUM =0; g =0; B = 0; meandr=0; S.f =figure('WindowState', 'maximized'); % % %b = uibutton(fig2, ... % "Text","Play", ... % "Icon","play.png", ... % "IconAlignment","top", ... % "Position",[100 100 50 50]); S.pb = uicontrol('style','push',... 'units','pix',... 'position',[10 10 180 40],... 'fontsize',14,... 'string','Обновить',... 'callback',{@pb_call,S}); distance(1:50) = 0; timearray(1:50) = 0; timestart = tic; B_scan = zeros(height, timePoint); startPointTime = 0; FFT0_delta = 5; while(1) files = dir("*.txt*"); new_siz = size(files,1); if new_siz> old_size pause(0.1); A = readmatrix(files(new_siz).name); if (SizeFirst== size(A,1)) if kpontInOneFqChange) signal(pos) = sum(mwanBmeandr(numberOfFreqChangeStart:numberOfFreqChange)); signalView(pos) = mean(mwanBmeandr(numberOfFreqChangeStart:numberOfFreqChange)); timeSignal(pos) = numberOfFreqChange; start = numberOfFreqChange; numberOfFreqChangeStart = numberOfFreqChange; pos = pos+1; end end %fig2 =figure(2); subplot(2,2,1); plot(time,abs(meanB(time)), time, meandr.*0.001, timeSignal, abs(signalView) ); xlabel('Такты (шт)') ylabel('Сигнал (мВ)') title('Данные с АЦП') %figure(3); ssS = size(signal,2); perpointFq = 10.67/ssS; XSignal = 3+ (1:1:ssS).*perpointFq; subplot(2,2,3); plot(XSignal, (abs(signal)) ); xlabel('Частота генератора(ГГц)') ylabel('Принятый сигнал (мВ)') title('Обработанные данные') %figure(4); subplot(2,2,2); F = fft(sqrt(abs(signal(1:FQend)))); Fshift = (abs(fftshift(F))); Fshift(ceil(FQend/2)-0:ceil(FQend/2)+0) = 0; FshiftS = smoothdata(Fshift,'gaussian',5); plot(FshiftS); xlim([0 FQend]); title('Фурье образ') % [pks,locs] = findpeaks(FshiftS,'MinPeakDistance',5,'Annotate','extents','SortStr','descend'); % text(locs+.02,pks,num2str((1:numel(pks))')) % ylim([-4 3]); % ylim([0 1.5]); %figure(5); subplot(2,2,4); if (timearray(1) == 0) timeend = toc(timestart2); timearray(1:50) = abs( timeend).*(1:50); else timeend = toc(timestart); timearray(1) = abs( timeend); end if startPointTime>timePoint startPointTime = 1 ; B_scan(:,startPointTime) = FshiftS(1 , ceil(FQend/2)+FFT0_delta: (ceil(FQend/2)+FFT0_delta+60-1) )'; B_scan(:,startPointTime+1) = zeros(1,height); imagesc(x,y,B_scan); % B_scan = circshift(B_scan,[0 1]); % B_scan(:,timePoint) = FshiftS(1, ceil(735/2): (ceil(735/2)+150-1) )'; %imagesc(B_scan); else B_scan(:,startPointTime) = FshiftS(1, ceil(FQend/2)+FFT0_delta: (ceil(FQend/2)+FFT0_delta+60-1) )'; B_scan(:,startPointTime+1) = zeros(1,height); imagesc(x,y,B_scan); end % for ooo =1:size(pks,2) % transparance = pks(ooo)/pks(1); % distance(1) = abs((ceil(735/2) - locs(ooo)) * 8/5); % xlim([1 100]); % plot(timearray(1),distance(1),'or','MarkerSize', transparance*12,"MarkerFaceColor",'r' ),hold on; % ylim([0 80]); % if timearray(1)>=100 % xlim([timearray(1)-100 timearray(1)]); % ylim([0 80]); % end % % distance = circshift(distance,1);, % % timearray = circshift(timearray,1); % end title('Дистанция до объекта') xlabel('Время (С)') ylabel('Дистанция (см)') end old_size = new_siz; end pause(0.01); end end function pb_call(varargin) %S = varargin{3}; % Get the structure. %set(S.h,'LineStyle','+') global update ; update = 1; end function R = updateData() R.startPointTime = 0 ; R.height = 60; R.timePoint = 100; R.B_scan = zeros(R.height, R.timePoint); end