how to draw peaks in specific locations?
1 view (last 30 days)
Show older comments
i need to draw peaks in specific coordinations how can i do it ?
Answers (1)
Star Strider
on 2 Aug 2014
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 Comments
Star Strider
on 5 Aug 2014
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.
See Also
Categories
Find more on Time-Frequency Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!