When Was That Goal Scored? - MATLAB Cody - MATLAB Central

Problem 43658. When Was That Goal Scored?

Difficulty:Rate

We want to find out when the goals were scored in a particular soccer game. For each game, we are given a "Goal Event Data" XML string from a soccer database. Your job is to pick out the "Elapsed Time" number for each goal. Return the numbers for each goal as a column vector of double precision numbers.

This translates to finding the number between the "<elapsed>" tags.

Example

Given this input

 ged = '<goal><value><elapsed>22</elapsed><subtype>header</subtype></value></goal>'

you should return the number 22.

Note that you must return the number 22 and not the string.

Feature Tip

R2016b introduces string arrays and text manipulation functions which can help. To learn more see MATLAB Characters and Strings.

Solution Stats

39.77% Correct | 60.23% Incorrect
Last Solution submitted on May 07, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers110

Suggested Problems

More from this Author50

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page