Adding elements to a column corresponding to the indices
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a matrix called as 'single_matrix_with_time_id', the first column corresponding to 'frame_number', second column corresponding to 'time', third column with 'identity', fourth column with 'error', fifth and sixth column with 'X and Y coordinates' and seventh column with 'Camera_id'.
What i am trying to do is to take the unique elements from the second column (time) and the elements corresponding to the unique elements of time from the 'first and seventh column' and add it to 'first, second and third column of ' a new matrix called 'final_plot_matrix'. I tried to do this in the code shown below, But it is not giving me the expected outcome. Any help will be appreciated. Mat file is attached
final_plot_matrix = nan(length(unique(single_matrix_with_time_id(:,2)))+1,length(final_filtered_ant_id)+3);
final_plot_matrix(1,4:length(final_filtered_ant_id)+3) = final_filtered_ant_id;
final_plot_matrix = repelem(final_plot_matrix,1,2);
final_plot_matrix(:,1) = [];
final_plot_matrix(:,2) = [];
final_plot_matrix(:,3) = [];
final_plot_matrix(2:length(unique(single_matrix_with_time_id(:,2)))+1,3) = unique(single_matrix_with_time_id(:,2));
[C,ia,ic] = unique(single_matrix_with_time_id(:,2));
frame_number = ia(single_matrix_with_time_id(:,1));
Camera_id = ia(single_matrix_with_time_id(:,3))
final_plot_matrix(2:length(unique(single_matrix_with_time_id(:,2)))+1,2) = frame_number
final_plot_matrix(2:length(unique(single_matrix_with_time_id(:,2)))+1,1) = Camera_id
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!