๐ Week 3 Homework โ Feedback
๐ Week 3 Homework โ Feedback
Student: Sofia Bruga
Files: week3_homework_starter.m, WB_RGDP.csv
Assignment: World Bank Real GDP & Growth (CSV version)
โ ๏ธ Overall Assessment
Result: โ ๏ธ Partially correct
The submission contains the script and a CSV, but the code does not run end-to-end due to an import/parsing error and a fragile filename split. After copying the CSV into the main folder, execution stops with:
Index exceeds the number of array elements. Index must not exceed 1.
Error in week3_homework_starter (line 41)
country_name = split_name{4};
Also, the CSV was placed in an Inout/ folder (typo) and not referenced correctly by the script.
๐ Whatโs going wrong
1) Header not parsed; all data in one โmegaโ column
Your preview shows a single variable named like
CountryName__CountryCode___IndicatorName___IndicatorCode___1960___...
This means readtable did not detect the header/delimiter correctly.
2) Fragile filename parsing
country_name = split_name{4}; assumes the filename contains at least 4 โ_โ tokens. It fails when that isnโt true. You shouldnโt read country names from the filename anywayโuse the table columns.
3) Non-reproducible path
CSV location (Inout/) doesnโt match the path in the code.
๐ง Task-by-Task Check
| Task | Description | Status | Notes |
|---|---|---|---|
| 1 | Import WB real GDP CSV | โ | Wrong import options; header/delimiter not detected. |
| 2 | Extract (country/iso3, year, value) |
โ | Blocked by import issue. |
| 3 | Build tidy long panel | โ | Not reached. |
| 4 | Compute logs & annual growth | โ | Not reached. |
| 5 | Verify US growth | โ | No plot. |
| 6 | Levels plot + legend | โ | Not produced. |
| 7 | Growth subplots + mean line | โ | Not produced. |
| 8 | Export panel CSV | โ | Not produced. |
โ Minimal fixes (match the reference CSV solution)
A) Robust import (header + delimiter)
fname = 'WB_RGDP.csv'; % place the CSV in the same folder as the script
opts = detectImportOptions(fname, 'Delimiter', ',');
opts.VariableNamesLine = 1; % header row
% If your file has metadata rows, uncomment the next line and adjust:
% opts.DataLines = [2, Inf];
T = readtable(fname, opts);
For the rest see solution files.