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

1 visualización (últimos 30 días)
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

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 5 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by