Save sub-matrix column and row in another matrix
Ältere Kommentare anzeigen
I have a 2D array with 4 column and many rows.
Month Day Year Value
xx xx xxxx xxx.xxxx
I want to enter the year from keyboard then save in an other matrix all the rows (month, day,year,value info) that contain the year from the input I entered. I've tried this
for idx = 1:numel(array)
element = array(idx);
if(element == month)
..... "Don't know how to do..."
end
end
thank you in advance
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 22 Okt. 2017
Bearbeitet: Andrei Bobrov
am 22 Okt. 2017
Let a - your array [Month Day Year Value]
out = a(a(:,3) == input_year,:);
1 Kommentar
giasco
am 23 Okt. 2017
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!