Info
This question is closed. Reopen it to edit or answer.
Give me an hint
3 views (last 30 days)
Show older comments
Hi,
I just need a hint of how to do a homework problem. Suppose I have this data: time = [1 2 3 4 5 6 7 8 9 10 11 12 13]' spike = [0 0 0 1 1 0 1 0 0 0 1 1 0]' Let me explain this. The zeros and ones indicate the presence and absence of spike, with zero being no spike and one being there is a spike. The time are in milliseconds and it corresponds to the spike. For example: there was a spike at 4msecs, 5 msecs, 7 msecs, 11msec and 12 msecs. The homework problem is to make a program to find the time in which the third spike occurred? The homework strictly states no loops allowed. Thank you
0 Comments
Answers (2)
Chad Greene
on 20 Apr 2015
Here's a hint. Run this:
% some data:
time = 1:20;
y = [1 1 0 2 3 4 3 5 6 4 3 12 3 5 4 7 4 11 15 4];
% Indices of all fours:
fours = find(y==4);
% Index of the third four:
thirdfour = fours(3);
% Time of third four:
time(thirdfour)
% plot all data:
plot(time,y,'bo')
% plot fours as red X marks:
hold on
plot(time(fours),y(fours),'rx')
xlabel('time')
box off
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!