Convert year data to month (40 years = 480 months) in rows

조회 수: 1 (최근 30일)
Felipe Michelin
Felipe Michelin 2015년 6월 25일
댓글: Felipe Michelin 2015년 7월 7일
Hi everyone!
I'm doing a research using Matlab and today it is my first month using it. However, I can't figure out how to solve my problem.
I have the estimate population for 40 years. The demand of water is calculated multiplying the population by the Galons per day. Each year's demand should by divided by 12 months which is multiplied for a factor.
For example:
Gallon per Day: 20;
Year: 2010...2040
Population: 500
Demand: 500 * 20 (Demand each year)
-
After this I should divide each year demand to 12 months and multiply by the month factor.
Ex:
Jan: Total year demand * 0.2 Feb: Total year demand * 0.8 ... Dec: Total year demand * 0 ---
After all calculations I should have an Array with 480 rows (40 years * 12 months) with every month value.
Ex:
Jan
.
.
Dez
Jan
.
The first thing that came to my mind is create a zeros(480,1) and replace it by the values.
So my question is, would someone just give me the way I should start? I don't know how to put all this answers in the same column.
  댓글 수: 3
Purushottama Rao
Purushottama Rao 2015년 6월 25일
is the month factor varies over the years?
Felipe Michelin
Felipe Michelin 2015년 6월 25일
편집: Felipe Michelin 2015년 6월 25일
First of all, thank you for the fast answers.
@Purushottama Rao
The factors are the same every year!
----
So, basically I import the population and factor data from Excel.
Population.pv = xlsread('data.xlsx','population','G3:G43');
factor = xlsread('prescott_data.xlsx','population','I3:I14');
What I need to do is create a variable "Demand" with 480 rows and calculate every month with their respective factor.
For example:
0 - (DemandYear2010/12 * factor.jan)
1 - (DemandYear2010/12 * factor.fev)
.
.
.
480 - (DemandYear2049/12 * factor.dez)
The "Population.pv" has 40 rows (2010 - 2050) and the "factor" has 12 (Jan - Dec)
If a drawing is better to understand I can do it!
Thank you so much!

댓글을 달려면 로그인하십시오.

채택된 답변

Mukul Rao
Mukul Rao 2015년 6월 26일
편집: Mukul Rao 2015년 6월 26일
Why not represent the results in a 40 by 12 matrix instead? Each row of the matrix would represent the consumption for the 12 months in the year. Here is how you would do this, I've made up some numbers for the sake of illustration :
population = (1:40)'; % 40 by 1 array
factor = (0.1:0.1:1.2)'; %12 by 1 array
demandperhead = (1:40)'; %You can replace this by a scalar
...if the demand is constant with year
yearlycontribution = (demandperhead .* population)/12 * factor';
%If you still would prefer an array format
yearlycontribution_array = reshape(yearlycontribution',1,480);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by