필터 지우기
필터 지우기

how to draw peaks in specific locations?

조회 수: 4 (최근 30일)
marc kahwaji
marc kahwaji 2014년 8월 2일
댓글: marc kahwaji 2014년 8월 5일
i need to draw peaks in specific coordinations how can i do it ?

답변 (1개)

Star Strider
Star Strider 2014년 8월 2일
Here is one way:
P = @(x,c,w) exp(-w*(x-c).^2); % Function to calculate peaks
W = 2; % Width (constant here, can vary as a vector if you like)
C = 5:5:15; % Peak centers
x = linspace(0,20,250); % Define ‘x’ vector
pks = zeros(size(x)); % Preallocate ‘pks’
for k1 = 1:length(C) % Loop through ‘C’ (centers) vector
pks = pks + P(x,C(k1),W);
end
figure(1) % Plot
plot(x,pks)
grid
produces:
  댓글 수: 13
Star Strider
Star Strider 2014년 8월 5일
I see you posted that Question and Image Analyst provided an appropriate Answer. Accepting Image Analyst’s Answer and mine here would be an appropriate response from you.
marc kahwaji
marc kahwaji 2014년 8월 5일
this is my serial data code
clear all; delete(instrfind); s = serial('COM6'); instrfind set(s, 'InputBufferSize', 256); set(s, 'FlowControl', 'none'); set(s, 'BaudRate', 9600); set(s, 'Parity', 'none'); set(s, 'Timeout',1);
disp(get(s,'Name')); prop(1)=(get(s,'BaudRate')); prop(2)=(get(s,'DataBits')); prop(3)=(get(s, 'StopBit')); prop(4)=(get(s, 'InputBufferSize'));
disp(['Port Setup Done!!',num2str(prop)]); fopen(s); instrfind
stopTime = '9/24 21:53'; time = now;
i=1; j=1;
while ~isequal(datestr(now,'mm/DD HH:MM'),stopTime)
d(i,j)=fscanf(s,'%f') %reading serial data and putting them in a matrix
e=d(:,1)' %values of the first sensor
f=d(:,end)' %values of the second sensor
subplot(1,2,1);
plot(e) %plotting the values of the first sensor
grid
subplot(1,2,2);
plot(f) %plotting the values of the second sensor
grid
j=j+1; if j==3 % if the index of columns of the matrix is 3
i=i+1; %we go to a new line of the matrix we increment the index of lines
j=1; %and we put the index of columns to 1
end ;
drawnow end; fclose(s); delete(s);
clear all;
i have serial data coming from two sensors.I'm putting them in a matrix then splitting them in two matrix: e and f. e contains the values of the first sensor and f contains the values of the second sensor. i need to draw two circles, one for each sensor, and i need to color them according to the values in matrix e and f. how can i do it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by