How can I create a matrice with values over a number of this matrix ?
1 view (last 30 days)
Show older comments
I have data of more than 18'000 earthquakes and I need to code a "for" loop that can find how many earthquakes >=7 occured.
I know how to use the loop, but I've no clue how to create a new matrice with all the earthquakes over 7 + a lign that counts them.
Thanks in advance !
0 Comments
Answers (1)
Star Strider
on 19 Apr 2023
Perhaps something like this —
earthquakes = rand(20,1)*9 % Data (Richter Magnitudes)
eq_gt7 = earthquakes>7 % Logical Vector
Nr_earthquakes_gt7 = nnz(eq_gt7) % Number Of Earthquakes > 7
earthquakes_gt7 = earthquakes(eq_gt7) % Magnitudes Of Earthquakes > 7
.
2 Comments
Star Strider
on 19 Apr 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
See Also
Categories
Find more on Earthquake Engineering 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!