start_id=[{'p1'};{'p2'};{'p1'};{'p1'};{'p3'}]; %cell
finish_id=[{'p2'};{'p3'};{'p3'};{'p4'};{'p4'}]; %cellpoints_id=[{'p1'};{'p2'};{'p3'};{'p4'}]; %cellm=numel(points_id);for i=1:m IndexC_minus(:,i) = strfind(start_id, points_id{i}); IndexC_positive(:,i) = strfind(finish_id, points_id{i}); end
I need to create IndexC_minus_double and IndexC_positive_double matrix as follows;
IndexC_minus_double=[-1 0 0 0;0 -1 0 0;-1 0 0 0;-1 0 0 0;0 0 -1 0]; %for each [1] cell, write -1 numeric and for each [] cell write 0 numeric.
IndexC_positive_double=[0 1 0 0;0 0 1 0;0 0 1 0;0 0 0 1;0 0 0 1]; %for each [1] cell, write 1 numeric and for each [] cell write 0 numeric.
Finally, I need to merge these 2 matrix as below;
merged_matrix=[-1 1 0 0;0 -1 1 0;-1 0 1 0;-1 0 0 1;0 0 -1 1]; % overlapped 0 produces 0 in the merged_matrix. The location of 1 and -1 in the IndexC_minus_double and IndexC_positive_double matrix are the same in the merged_matrix.
Best Answer