Values of an array should be equal to or greater than the value before - values of array in relation to one another

3 ビュー (過去 30 日間)
Hi !
So I am working on a project for a final, wherein we are to write a MATLAB program to visualize the global COVID-19 pandemic spread, and predict the situation over the next month. The first step of this project is fixing inacurrate entries within the data sets. The instructions are as follows:
The original data files have noises, or inaccurate entries. For example, the confirmed cases should not ever decrease for a particular region, because it is supposed to be the total number of cases up to each date. The same is true for the number of deaths and recovered cases. Identify and correct those inaccurate entries. You can use interpolation to find the best estimation of those erroneous data.
I am confused as to how to write a code that will determine if a value within the each row of the array is not greater than or equal to the value before it. Thank you!

回答 (1 件)

Isiah Pham
Isiah Pham 2020 年 5 月 8 日
So if I have a matrix of cases = [1:10,9], you can use a for loop to go through each number in the matrix and check that it is greater than the previous number.
To predict what the value should be, you can make a polynomial that would fit your data using the function polyfit(xdata, ydata, n). N is the degree of the polynomial, and polyfit creates a polynomial with that degree that would best fit the data. With the polynomial, you can use polyval() to get the interpolation with the regression equation.

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by