views:

49

answers:

1

Hello,

Could you please help me for this matter?

I have 3 matrices, P (Power), T (Temperature) and H (Humidity)

every matrix has 31 columns (days) and there are 24 rows for every column

which are the data for the March of year 2000, i.e.

for example, the matrix P has 31 columns where every column represents

a day data for Power through 24 hours and the same idea is for T and H

I tried to write a MATLAB program that accomplish my goal but

It gave me errors.

My aim is:

In the MATLAB command window, the program should ask the user the following phrase:

Please enter the day number of March, 2000 from 1 to 31:

And I know it is as follows:

Name=input (Please enter the day number of March, 2000 from 1 to 31:)

Then, when, for example, number 5 is entered, the result shown is a matrix containing the following:

1st column: The day name or it can be represented by numbers

2nd column: simple numbers from 1 to 24 representing the hours for that day

3rd column: the 24 points of P of that day extracted from the original P (the column number 5 of the original P)

4th column: the 24 points of T of that day extracted from the original T (the column number 5 of the original T)

5th column: the 24 points of H of that day extracted from the original H (the column number 5 of the original H)

Any help will be highly appreciated,

Regards

A: 

Here is what you ask for:

% some sample data
P = rand(24,31);
T = rand(24,31);
H = rand(24,31);
% input day number
daynum=input('Please enter the day number of March, 2000 from 1 to 31: ');
[r, c] = size(P);
% generate output matrix
OutputMatrix = zeros(r,5);
OutputMatrix(:,1) = repmat(weekday(datenum(2000,3,daynum)),r,1);
OutputMatrix(:,2) = 1:r;
OutputMatrix(:,3) = P(:,daynum);
OutputMatrix(:,4) = T(:,daynum);
OutputMatrix(:,5) = H(:,daynum);
disp(OutputMatrix)

The matrix can be generated in a one line, but this way is clearer.

Is it always for March 2000? :) Where do you get this information from?

yuk
Thanks for this help. Actually, I have a huge data for many years but this is only a sample. This is related to my master thesis works. But how now if we want to make the program wider, I mean take the whole year rather than a single month, then do as above but now pressing a month number then a day number, and finally plot the resultant P vs index (24 hours ) for the selected day.
Thanks a lot. The program is perfect, but the first column should represent the day name , Monday or tuesday, ...etc, it is not the day number. regards
How your data is organized? Or do you need an advice how to organize the data? What is your MATLAB experience? Cause nobody will do the whole project for you.
yuk
Ah, you need weekday. Replace `OutputMatrix(:,1) = repmat(weekday(datenum(2000,3,daynum)),r,1);` (Sunday is 1).
yuk
The above example you wrote helped me alot and I will try to modify it to make a wider analysis, I am not expert in Matlab but at least I have some experience and background in writing programs. and for a sample only I asked about one month, then I will try to apply the same as your idea to choose a month from the year, then choose a day from that month. regards
My data is organized as done for March, all other months have the same idea.
How do you name your matrices for other months? Do you use structures? Multidimention arrays?
yuk
If the answer is helpful please consider to upvote and accept it.
yuk
I have the same building matrix for March, meaning that:I call the P_jan, P_feb,.....P_dec and each matrix has its different values but the structure is the same: # of days of the month as columns and 24 rows representing the hours. These matrices have been copied from av excel file that registred these values from a real data done experimentally and in the field.Many classifications can be done , e.g taking the whole data and representing it in one matrix called P_year2000 or dividing the year to matrices as done above. regards

related questions