extract values from a table (2024)

74 views (last 30 days)

Show older comments

Viktoriya on 30 Nov 2022

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table

Commented: Cris LaPierre on 1 Dec 2022

I have a mat file that is a table with a lot of values for temperatures on each given day of each month of several years for different location. I need to extract from this file one location and the mean of each month. Everything I tried doesnt work.

4 Comments

Show 2 older commentsHide 2 older comments

Voss on 30 Nov 2022

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493528

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493528

Can you attach the .mat file and some of the code you tried?

Viktoriya on 30 Nov 2022

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493563

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493563

The file is to large to get attached and I didnt save the code, but I tried to use the find function and it failed.

Voss on 30 Nov 2022

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493593

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493593

Open in MATLAB Online

Can you make a smaller table (i.e., less data but similar format), save that to a .mat file, and upload it?

For example, maybe just the first several rows of the table

t_new = t(1:10,:); % just the first 10 rows

save('table.mat','t_new');

(Maybe it's better to try to save the first 1000 or 100 rows instead of 10, depending on how stuff is arranged in the table.)

Alternatively, maybe a screen shot will be enough to figure it out.

Viktoriya on 30 Nov 2022

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493618

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2493618

  • Capture.PNG

basically that's the data I have (it continues further). I tried to do this to extract the data, bt it doesnt give much:

extract values from a table (6)

s =load('data_sectionM.mat') ;

year=SECTION_M(1,:);

month=SECTION_M(2,:);

day=SECTION_M(3,:);

temp=SECTION_M(67,:);

mydata=[year;month;day;temp];

newtable=table(year, month, day, temp)

Sign in to comment.

Sign in to answer this question.

Answers (2)

Cris LaPierre on 30 Nov 2022

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#answer_1116708

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#answer_1116708

Open in MATLAB Online

If this is of datatype table, you might find the Access Data in Tables page helpful.

You describe selecting data using multiple criteria, and a desire to compute a summary stat based on those criteria. To me, that suggests using groupsummary. I find logical indexing works well for selecting rows to extract.

% Create a sample data set

date = datetime(2020,1,1):days(1):datetime('now');

date=date';

location = ones(size(date));

location(2:2:end)=2;

data=rand(size(date));

Tbl = table(date,location,data)

Tbl = 1065×3 table

date location data ___________ ________ ________ 01-Jan-2020 1 0.66702 02-Jan-2020 2 0.56336 03-Jan-2020 1 0.26084 04-Jan-2020 2 0.93963 05-Jan-2020 1 0.81655 06-Jan-2020 2 0.05855 07-Jan-2020 1 0.16368 08-Jan-2020 2 0.037964 09-Jan-2020 1 0.89949 10-Jan-2020 2 0.28405 11-Jan-2020 1 0.27924 12-Jan-2020 2 0.74075 13-Jan-2020 1 0.34463 14-Jan-2020 2 0.39209 15-Jan-2020 1 0.67204 16-Jan-2020 2 0.72051

mnTbl = groupsummary(Tbl,["location","date"],["none","month"],"mean","data")

mnTbl = 70×4 table

location month_date GroupCount mean_data ________ __________ __________ _________ 1 Jan-2020 16 0.53365 1 Feb-2020 14 0.40572 1 Mar-2020 16 0.55608 1 Apr-2020 15 0.5417 1 May-2020 15 0.44745 1 Jun-2020 15 0.53494 1 Jul-2020 16 0.49 1 Aug-2020 15 0.43882 1 Sep-2020 15 0.57664 1 Oct-2020 16 0.52817 1 Nov-2020 15 0.57053 1 Dec-2020 15 0.53841 1 Jan-2021 16 0.55658 1 Feb-2021 14 0.6917 1 Mar-2021 15 0.51216 1 Apr-2021 15 0.54087

% Extract location 2, Feb 2021

mnTbl(mnTbl.location==1 & string(mnTbl.month_date)=="Feb-2021","mean_data")

ans = table

mean_data _________ 0.6917

1 Comment

Show -1 older commentsHide -1 older comments

Cris LaPierre on 1 Dec 2022

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2494658

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#comment_2494658

Open in MATLAB Online

MATLAB Tables place variables in columns, so I would do something like this based on the code you have shared.

load('data_sectionM.mat') ;

SECTION_M = SECTION_M.';

long = SECTION_M(1,4:end);

lat = SECTION_M(2,4:end);

year=SECTION_M(4:end,1);

month=SECTION_M(4:end,1);

day=SECTION_M(4:end,3);

temp=SECTION_M(4:end,67);

date = datetime(year,month,day);

newtable=table(date, temp);

% Now with the data in a table, you can start analyzing your data.

mnTbl = groupsummary(newtable,"date","month","mean","temp")

Sign in to comment.

Voss on 30 Nov 2022

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#answer_1116773

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/1867883-extract-values-from-a-table#answer_1116773

Edited: Voss on 30 Nov 2022

Open in MATLAB Online

It looks like, basically row 1 is year, row 2 is month, row 3 is day of month, and row 4 through the end are temperature data for various locations, and that the locations' longitude and latitude are given in columns 1 and 2.

Here's a smaller approximation of that matrix (with random temperatures every day for 2 years at 1 location):

SECTION_M = [ ...

NaN(1,3) 1975*ones(1,365) 1976*ones(1,366); ...

NaN(1,3) repelem(1:12,[31 28 31 30 31 30 31 31 30 31 30 31]) repelem(1:12,[31 29 31 30 31 30 31 31 30 31 30 31]); ...

NaN(1,3) 1:31 1:28 1:31 1:30 1:31 1:30 1:31 1:31 1:30 1:31 1:30 1:31 1:31 1:29 1:31 1:30 1:31 1:30 1:31 1:31 1:30 1:31 1:30 1:31; ...

-179 45 NaN 100*rand(1,365+366); ...

];

disp(SECTION_M);

1.0e+03 * Columns 1 through 19 NaN NaN NaN 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 NaN NaN NaN 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 NaN NaN NaN 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 -0.1790 0.0450 NaN 0.0880 0.0562 0.0274 0.0660 0.0245 0.0789 0.0193 0.0785 0.0653 0.0229 0.0116 0.0896 0.0959 0.0906 0.0626 0.0997 Columns 20 through 38 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0020 0.0020 0.0020 0.0020 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0164 0.0642 0.0851 0.0822 0.0970 0.0702 0.0909 0.0386 0.0772 0.0655 0.0737 0.0180 0.0141 0.0036 0.0453 0.0826 0.0608 0.0201 0.0701 Columns 39 through 57 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0377 0.0239 0.0768 0.0866 0.0594 0.0559 0.0257 0.0816 0.0757 0.0099 0.0662 0.0845 0.0528 0.0809 0.0722 0.0901 0.0666 0.0984 0.0783 Columns 58 through 76 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0020 0.0020 0.0020 0.0020 0.0020 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0240 0.0250 0.0260 0.0270 0.0280 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0111 0.0049 0.0618 0.0055 0.0614 0.0312 0.0089 0.0080 0.0831 0.0299 0.0954 0.0332 0.0996 0.0316 0.0996 0.0259 0.0966 0.0954 0.0492 Columns 77 through 95 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0040 0.0040 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0501 0.0686 0.0631 0.0383 0.0403 0.0144 0.0269 0.0752 0.0703 0.0588 0.0061 0.0230 0.0869 0.0981 0.0616 0.0628 0.0322 0.0008 0.0502 Columns 96 through 114 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0313 0.0769 0.0972 0.0323 0.0658 0.0056 0.0399 0.0213 0.0117 0.0831 0.0949 0.0693 0.0755 0.0093 0.0432 0.0172 0.0738 0.0173 0.0446 Columns 115 through 133 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0752 0.0998 0.0582 0.0393 0.0391 0.0521 0.0941 0.0824 0.0890 0.0349 0.0369 0.0830 0.0870 0.0838 0.0504 0.0041 0.0219 0.0980 0.0095 Columns 134 through 152 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0681 0.0487 0.0657 0.0533 0.0905 0.0657 0.0150 0.0521 0.0325 0.0461 0.0823 0.0810 0.0721 0.0024 0.0278 0.0334 0.0991 0.0808 0.0656 Columns 153 through 171 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0050 0.0050 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0129 0.0123 0.0366 0.0502 0.0441 0.0431 0.0619 0.0005 0.0370 0.0825 0.0837 0.0601 0.0150 0.0947 0.0335 0.0453 0.0457 0.0044 0.0398 Columns 172 through 190 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0939 0.0210 0.0773 0.0331 0.0962 0.0848 0.0252 0.0147 0.0332 0.0036 0.0927 0.0592 0.0348 0.0797 0.0209 0.0548 0.0301 0.0277 0.0530 Columns 191 through 209 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0720 0.0026 0.0291 0.0382 0.0792 0.0642 0.0485 0.0394 0.0497 0.0934 0.0646 0.0676 0.0735 0.0517 0.0109 0.0676 0.0674 0.0716 0.0140 Columns 210 through 228 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0219 0.0286 0.0437 0.0419 0.0868 0.0768 0.0106 0.0268 0.0835 0.0454 0.0325 0.0248 0.0021 0.0922 0.0010 0.0064 0.0997 0.0827 0.0919 Columns 229 through 247 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0090 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0136 0.0443 0.0433 0.0857 0.0572 0.0064 0.0943 0.0703 0.0393 0.0224 0.0981 0.0920 0.0352 0.0238 0.0281 0.0645 0.0873 0.0097 0.0948 Columns 248 through 266 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0178 0.0865 0.0820 0.0191 0.0332 0.0056 0.0182 0.0741 0.0235 0.0111 0.0130 0.0588 0.0348 0.0716 0.0981 0.0134 0.0104 0.0829 0.0795 Columns 267 through 285 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0067 0.0482 0.0294 0.0019 0.0102 0.0813 0.0448 0.0735 0.0511 0.0980 0.0801 0.0000 0.0967 0.0707 0.0883 0.0387 0.0506 0.0372 0.0564 Columns 286 through 304 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0858 0.0607 0.0511 0.0953 0.0909 0.0672 0.0338 0.0229 0.0268 0.0876 0.0958 0.0044 0.0574 0.0548 0.0480 0.0810 0.0646 0.0583 0.0975 Columns 305 through 323 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0100 0.0100 0.0100 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0046 0.0384 0.0201 0.0340 0.0317 0.0847 0.0032 0.0856 0.0006 0.0258 0.0707 0.0861 0.0446 0.0664 0.0658 0.0257 0.0925 0.0111 0.0929 Columns 324 through 342 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0120 0.0120 0.0120 0.0120 0.0120 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0020 0.0030 0.0040 0.0050 0.0470 0.0585 0.0214 0.0244 0.0350 0.0020 0.0058 0.0541 0.0189 0.0602 0.0218 0.0433 0.0467 0.0316 0.0508 0.0654 0.0178 0.0893 0.0651 Columns 343 through 361 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0257 0.0551 0.0356 0.0420 0.0199 0.0900 0.0123 0.0838 0.0440 0.0232 0.0729 0.0568 0.0899 0.0328 0.0826 0.0561 0.0483 0.0336 0.0469 Columns 362 through 380 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9750 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0558 0.0717 0.0624 0.0887 0.0053 0.0207 0.0225 0.0457 0.0990 0.0842 0.0829 0.0630 0.0549 0.0174 0.0598 0.0075 0.0580 0.0251 0.0066 Columns 381 through 399 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0249 0.0816 0.0850 0.0589 0.0702 0.0580 0.0148 0.0977 0.0952 0.0921 0.0821 0.0416 0.0665 0.0682 0.0920 0.0431 0.0256 0.0752 0.0831 Columns 400 through 418 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0251 0.0379 0.0639 0.0753 0.0528 0.0806 0.0120 0.0749 0.0751 0.0742 0.0103 0.0087 0.0648 0.0920 0.0360 0.0802 0.0401 0.0234 0.0918 Columns 419 through 437 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0667 0.0347 0.0372 0.0004 0.0575 0.0571 0.0071 0.0317 0.0873 0.0433 0.0439 0.0961 0.0699 0.0796 0.0235 0.0321 0.0542 0.0150 0.0861 Columns 438 through 456 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0281 0.0544 0.0979 0.0869 0.0202 0.0943 0.0388 0.0577 0.0791 0.0669 0.0881 0.0439 0.0239 0.0702 0.0990 0.0000 0.0049 0.0080 0.0580 Columns 457 through 475 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0030 0.0030 0.0030 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0281 0.0902 0.0387 0.0408 0.0537 0.0562 0.0095 0.0039 0.0314 0.0745 0.0863 0.0965 0.0461 0.0272 0.0442 0.0201 0.0731 0.0021 0.0914 Columns 476 through 494 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0050 0.0050 0.0050 0.0050 0.0050 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0020 0.0030 0.0040 0.0050 0.0300 0.0601 0.0488 0.0570 0.0186 0.0681 0.0138 0.0560 0.0098 0.0045 0.0589 0.0265 0.0594 0.0865 0.0329 0.0503 0.0532 0.0643 0.0316 Columns 495 through 513 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0841 0.0221 0.0893 0.0669 0.0526 0.0562 0.0908 0.0957 0.0746 0.0481 0.0274 0.0699 0.0981 0.0011 0.0772 0.0719 0.0733 0.0702 0.0836 Columns 514 through 532 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0240 0.0976 0.0577 0.0318 0.0766 0.0655 0.0546 0.0216 0.0932 0.0701 0.0456 0.0672 0.0043 0.0411 0.0210 0.0634 0.0753 0.0146 0.0680 Columns 533 through 551 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0070 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0884 0.0260 0.0362 0.0838 0.0649 0.0531 0.0633 0.0323 0.0551 0.0219 0.0059 0.0630 0.0917 0.0909 0.0559 0.0506 0.0381 0.0990 0.0078 Columns 552 through 570 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0949 0.0404 0.0398 0.0208 0.0060 0.0923 0.0471 0.0503 0.0301 0.0345 0.0277 0.0675 0.0159 0.0072 0.0745 0.0163 0.0237 0.0693 0.0816 Columns 571 through 589 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0819 0.0545 0.0234 0.0569 0.0835 0.0780 0.0091 0.0296 0.0420 0.0572 0.0205 0.0772 0.0297 0.0296 0.0929 0.0808 0.0719 0.0953 0.0018 Columns 590 through 608 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0468 0.0059 0.0181 0.0309 0.0155 0.0959 0.0154 0.0718 0.0148 0.0964 0.0972 0.0047 0.0480 0.0222 0.0424 0.0778 0.0173 0.0969 0.0332 Columns 609 through 627 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0080 0.0080 0.0080 0.0080 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0793 0.0675 0.0750 0.0680 0.0974 0.0445 0.0380 0.0653 0.0417 0.0559 0.0541 0.0621 0.0471 0.0190 0.0609 0.0410 0.0835 0.0143 0.0655 Columns 628 through 646 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0090 0.0100 0.0100 0.0100 0.0100 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0010 0.0020 0.0030 0.0040 0.0927 0.0557 0.0093 0.0796 0.0767 0.0742 0.0443 0.0070 0.0622 0.0579 0.0937 0.0219 0.0081 0.0664 0.0821 0.0249 0.0994 0.0775 0.0107 Columns 647 through 665 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0292 0.0923 0.0263 0.0787 0.0517 0.0411 0.0713 0.0405 0.0711 0.0444 0.0788 0.0727 0.0770 0.0942 0.0704 0.0505 0.0927 0.0142 0.0849 Columns 666 through 684 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0364 0.0241 0.0251 0.0232 0.0365 0.0074 0.0348 0.0177 0.0438 0.0006 0.0310 0.0918 0.0145 0.0523 0.0606 0.0944 0.0400 0.0178 0.0069 Columns 685 through 703 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0170 0.0911 0.0560 0.0446 0.0838 0.0290 0.0459 0.0639 0.0147 0.0999 0.0694 0.0608 0.0570 0.0843 0.0938 0.0864 0.0102 0.0973 0.0737 Columns 704 through 722 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0457 0.0247 0.0545 0.0605 0.0345 0.0318 0.0513 0.0555 0.0794 0.0242 0.0089 0.0792 0.0738 0.0069 0.0254 0.0643 0.0713 0.0357 0.0210 Columns 723 through 734 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 1.9760 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0120 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290 0.0300 0.0310 0.0006 0.0055 0.0120 0.0662 0.0434 0.0233 0.0125 0.0091 0.0912 0.0461 0.0755 0.0110

Here's how you can get the average temperature for each month across all years (so 12 avg temps total, one per month) at a given location:

month_row = 2;

location_row = 4; % change this to the location you want, e.g., 67

monthly_avg_temp = groupsummary(SECTION_M(location_row,4:end).', SECTION_M(month_row,4:end).', @mean)

monthly_avg_temp = 12×1

59.3405 53.3945 53.9037 49.0855 56.6118 50.8872 47.6641 50.5729 49.9303 54.2795

Or, to get the average temperature for each month in each year (24 avg temps in this case - one per month for 2 years) at a given location:

year_row = 1;

month_row = 2;

location_row = 4; % change this to the location you want, e.g., 67

monthly_avg_temp = groupsummary(SECTION_M(location_row,4:end).', SECTION_M([year_row month_row],4:end).', @mean)

monthly_avg_temp = 24×1

58.6822 57.1949 53.6867 53.0089 52.1626 48.2590 50.6785 48.8743 45.7980 56.9550

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABLanguage FundamentalsData TypesTables

Find more on Tables in Help Center and File Exchange

Tags

  • file
  • mean
  • extract

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


extract values from a table (10)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

extract values from a table (2024)
Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5868

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.