MATLAB: Help writing a script which outputs the daily percentage of positive COVID-19 cases

MATLABnovice

Hello all,
I'm trying to write a script which gives the daily percentage of positive COVID-19 cases for Oregon. So far I have
%Analysis of daily percentage of positive COVID-19 test in the state of Oregon
clc
clear all
close all
%load data from https://covidtracking.com/data/state/oregon
api='https://covidtracking.com/api/v1/states/OR/daily.json'
data=webread(api)
This gives a 76×1 cell with all 1×1 structres. I would like to get the data from these structers so I can use the variables to produce a best fit using either one of the two equations 1/x/a/sqrt(2*pi)*exp(-(log(x)-b)^2/2/a^2) where a,b are variables.

Best Answer

This shows how to extract data from a particular field
api='https://covidtracking.com/api/v1/states/OR/daily.json';
data=webread(api);
dataTotal = cellfun(@(x) x.('total'), data);
dataPositive = cellfun(@(x) x.('positive'), data);
dataNegative = cellfun(@(x) x.('negative'), data);