function [country,C,date0] = getDataUSA_CDC() Error: Function definition not supported in this context. Create functions in code file.

1 view (last 30 days)
Hello ! I'm trying to run this code but it gives me the error as stated in the tile. Can anyone help me out with this ? Thank you.
function [country,C,date0] = getDataUSA_CDC()
%GETDATA Coronavirus data
% https://www.cdc.gov/coronavirus/2019-ncov/cases-updates/cases-in-us.html
country = 'USA_CDC';
date0=datenum('2020/03/01'); % start date
C = [
30 % 3/1/2020
53 % 3/2/2020
80 % 3/3/2020
98 % 3/4/2020
164 % 3/5/2020
214 % 3/6/2020
279 % 3/7/2020
423 % 3/8/2020
647 % 3/9/2020
937 % 3/10/2020
1215 % 3/11/2020
1629 % 3/12/2020
1896 % 3/13/2020
2234 % 3/14/2020
3487 % 3/15/2020
4226 % 3/16/2020
7038 % 3/17/2020
10442 % 3/18/2020
15219 % 3/19/2020
18747 % 3/20/2020
24583 % 3/21/2020
33404 % 3/22/2020
44183 % 3/23/2020
54453 % 3/24/2020
68440 % 3/25/2020
85356 % 3/26/2020
103321 % 3/27/2020
122653 % 3/28/2020
140904 % 3/29/2020
163539 % 3/30/2020
186101 % 3/31/2020
213144 % 4/1/2020
239279 % 4/2/2020
277205 % 4/3/2020
%<-------------- add new data here
]';
end

Accepted Answer

Geoff Hayes
Geoff Hayes on 5 May 2020
Hemanth - I suspect that you are copying and pasting this code into the command window. Since this code is a function (as given by the function signature) then it needs to be saved to a file (with the name getDataUSA_CDC.m). You can then call this function from the command line as
>> [country,C,date0] = getDataUSA_CDC();
Note how this is equivalent to the function signature less the function keyword.

More Answers (0)

Categories

Find more on Programming 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!