MATLAB Answers

Adding elements to a column corresponding to the indices

1 ビュー (過去 30 日間)
Hari krishnan
Hari krishnan 2018 年 9 月 7 日
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 件)


Translated by