how to draw peaks in specific locations?

4 次查看(过去 30 天)
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