Values of an array should be equal to or greater than the value before - values of array in relation to one another
1 次查看(过去 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!
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!