Need help in creating a code
조회 수: 3 (최근 30일)
이전 댓글 표시
A town has a population census every 10 years. The results of the census are shown below. Create a spreadsheet and MATLAB Script that to return the estimation of the value of the population of the town for any year between 1900 and 2000.Make your script interactive in case there is a change in data.
댓글 수: 9
Rik
2021년 5월 13일
What syntax are you using in fprintf? Or are you still using disp? If you want a specific format, you should not be using disp.
답변 (2개)
Steven Lord
2021년 5월 13일
Change the format you use to display the data.
year=[1900:10:2000];
pop=[550 720 1265 2287 2756 3012 4086 5220 7478 10112 14226];
n_year = 1955:3:1995;
n_pop= interp1(year, pop, n_year,'spline');
format % use the default display format
data = [n_year.', n_pop.']
format longg % use a different format
data
You could even create a table array of your data.
T = table(n_year.', n_pop.', 'VariableNames', {'Year', 'Population'})
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!