How to extract certain cells from one column based on the information in another column using data from imported file?

22 Ansichten (letzte 30 Tage)
So i imported a database (csv file) into Matlab. When imported, i converted the file into a 210x18 table. Some columns contain data in the form of strings while other columns contain only numbers. Im trying to figure out how to extract certain data from one column based on the information in other columns.
For example, I have this imported table below. I want to extract the values in column 3 for each row that contains a "2016" in column 1 and contains a "QC" in column 2.
I initially tried converting it into a table, sorting column 1 by ascending years, and then extracting all the values from column c but im looking for an easier way of going about this. Also to note, some of the cells in my 210x18 table have NaN.
thanks!!

Antworten (1)

Walter Roberson
Walter Roberson am 25 Nov. 2022
mask = Book1.Year == 2016 & Book1.Province == "QC";
subset = Book1(mask,:);

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by