MATLAB Answers


how to use logic array

Asked by karishma koshy on 1 Aug 2019
Latest activity Commented on by Jon
on 2 Aug 2019
i have a 8x6 logical array
result1 =
8×6 logical array
1 0 0 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 0 0 1
0 0 0 0 0 0
how to use this logical array to extract the values in two matrix assosiated with logical ones


I am trying to locate the values that linked to the logical ones. So that I can identify it's movement and add the ID number later on.
So all I want is a for loop where I can take the size of row_frame1_data array, use the assignment matrix that i get from the Munkres algorithm to find out which points in adjacent frames have been linked.
on 1 Aug 2019
@karishma, you asked this question already and I asked for clarification. Instead of clarifying you deleted that question and reposted it with even less information.... and you get asked the same clarifications.
So,if you want help, rather than wasting everybody's time do answer the questions that you're asked and spend time explaining everything clearly.
The question that you deleted was a lot better expressed than what you've written above even though it wasn't clear. It's even less clear now.
Personally, I won't contribute anymore since my input wasn't thought worthwile.
Hi Sir
I thought it was not clear and had less information. That why I resubmitted it added informations. Sorry for your inconvenience.

Sign in to comment.

2 Answers

Answer by Jon
on 1 Aug 2019
 Accepted Answer

It isn't quite clear the specifics of what you want to retrieve but for example if you wanted to get the row in frame 1 that matches row 2 in frame 2 you could use
row = row_frame1_adata(result1(:,2),:)


on 2 Aug 2019
It sounds like you have a fairly clear understanding of what you want your code to do. You just need to translate your written description into MATLAB code that implements it. Just think carefully about each step you describe and I think you will be able to come up with the detailed MATLAB implementation. If you encounter some behavior that you really can't understand, or are stuck at some very specific point then ask for more help, but I think at this point you should be able to work out the details.
Dear Sir,
I know what to do theoretically, but I'm new to coding.
That's why I am stuck with this.
on 2 Aug 2019
Your application is quite complicated and probably is not a good place to start learning how to code. I would suggest that if you have not done so already you should first complete the free MATLAB On Ramp training,
Make sure you work your way all the way through this and don't skip any steps.
After you complete the training and come back to your problem I think you will find you will be able to code a solution.

Sign in to comment.

Answer by Jackson Burns on 1 Aug 2019

You can use Masking to index your array of results. Try this:
Where row_frame_data is the 8*6 atrix of results and result1 is the logical matrix of the values you want.


Show 1 older comment
Exactly. Why is your logical matrix not the same size as the matrix you want to extract the values from. Your logical matrix has 4 more columns than your data. Why???
In horizontal it's the number of elements in frame k and in vertical it's the number of elements in frame k+1 ie it's 8x6 array. The logical array was obtained using Hungarian algorithm
You will need to adjust the dimensions of your logical array to match the data.

Sign in to comment.