Question regarding error occured
Afficher commentaires plus anciens
X = importdata('owid-covid-data_2020-21.csv');
john_data = X.textdata;
X_s = string(john_data);
data = X.data;
d = X_s(:,4);
A = zeros(4,396);
n=0;
for i = 1:length(X_s)
for k = 1:length(data)
for j = 1:length(d)
if j < 396
n = n+1;
C = X_s(k);
s_d = d(n(1));
e_d = d(n);
N_r = sum((e_d:s_d));
A = [C, s_d,e_date,N_r]';
fprintf('%12s %13s %13s %13s\n','Country name', 'Record start date','Record end date','Number of records')
fprintf('%15f %15f %15f %15f\n',A)
end
end
end
end
The question asked us to pick data from the file which is country that has day tracked less than 396 and print to a table contains Country Name, Record start date, Record end date and number of records in the command window, how am I to find those data and print it to the screen? is my loop have any problem and it won't run
1 commentaire
Jan
le 19 Mai 2022
You mention, that an error occurs. Please post a copy of the complete message.
n is a scalar. Then:
s_d = d(n(1));
e_d = d(n);
replies the same value. In consequence
N_r = sum((e_d:s_d));
is the same as:
N_r = e_d; % or s_d
Réponses (0)
Catégories
En savoir plus sur Tables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!