Could someone please help me create a three-column array?

조회 수: 3 (최근 30일)
Student
Student 2016년 4월 11일
편집: Image Analyst 2022년 10월 18일
I have "NYC Diseases" data with the following 4 variables:
  1. chickenPox (41x12 double)
  2. measles (41x12 double)
  3. mumps (41x12 double)
  4. years (41x1 double)
The rows are the years, and the 12 columns are the 12 months. I am told to load the NYC diseases data sets (NYCDiseases.mat).
Create variable called diseases that holds a three-column array.
The first column is the monthly counts of measles, the second column is the monthly counts of mumps, and the third column is the monthly counts of chicken pox.
Could anyone help me on how I should approach this type of command? Would I be using the "reshape"?
Thank you. I'd really appreciate help on this.
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 4월 11일
You have not given us sufficient information about the correspondence between the 41x12 and "monthly counts". If we assume that the 12 corresponds to the 12 months of the year and each row corresponds to a year whose number is given in years then we still need to know whether the array is to have 41*12 rows or if it is to have 12 rows where the counts are total counts per month over all of the years.

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

채택된 답변

Roger Stafford
Roger Stafford 2016년 4월 11일
편집: Image Analyst 2022년 10월 18일
Here is my guess as to what you mean:
M = [mean(measles,1).', mean(mumps,1).', mean(chickenPox,1).'];
Each value in M is the average number of the respective diseases over the 41 year period for the month corresponding to the row number. There will be 12 rows (each row is a different month) and 3 columns for the 3 diseases.

추가 답변 (2개)

Mariana
Mariana 2022년 10월 18일
For anyone here looking for this from 2022 and on, its:
diseases = [sum(measles,1).',sum(mumps,1).',sum(chickenPox,1).'];

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 11일
out=[measles(:),mumps(:),chickenPox(:)]

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by