Adding elements to a column corresponding to the indices
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!