finding data from a big matrix
Show older comments
Hello,
I have the followin question: I have a big matrix A (1140X837).With help of Matlab I calculated the following data [av index] =sort( FinalAverage). Where av is matrix (1140X1) and contains a column that has zeors and some non-zero numbers that are the averages. In matrix index (1140X1) there is a column that has numbers that correspond to the zeros and its averages from matrix av. Now I am trying to find in matrix A what meaning were given by the numbers on the matrix where I told you above they put an average.(matrix av) . How can I automate in matlab, that is, find what average they put in matrix A (this is true for those who out an average in matrix av).
Your help is important.
19 Comments
darova
on 30 May 2019
Can you please your code or some example?
FinalAverage = mean(A,2);
[av index] = sort(FinalAverage);
Now you want to know how index and A related?
Rik
on 30 May 2019
I agree with darova, please try to post a small example that explains your input and output.
stelios loizidis
on 30 May 2019
stelios loizidis
on 30 May 2019
stelios loizidis
on 30 May 2019
darova
on 30 May 2019
Is there any relation between matrix A and av?
stelios loizidis
on 31 May 2019
Jan
on 31 May 2019
I cannot follow the explanations.
A(2,4)=4: this means that visitors 4 put a rating of 4 at location 4
Isn't this the location 2 instead of 4?
This code:
FinalAverage = mean(A,2);
[av index] = sort(FinalAverage);
does not produce these data:
A=[0 2 5 3 1
2 3 4 5 3
3 3 3 3 2
1 4 5 6 2
5 5 4 1 0
2 3 5 4 2]
av=[0
0
0
2
3
5]
index=[5
10
30
45
2
31]
Therefore I still do not understand, what you are currently doing nor what you want to achieve. The physical meaning of the values in matrix A is not important, but the relation between its values and the posted outputs.
stelios loizidis
on 1 Jun 2019
darova
on 1 Jun 2019
what we gonna do about this?
Rik
on 1 Jun 2019
I fully agree with Jan, and I think that what he posted is the core this question:
Therefore I still do not understand, what you are currently doing nor what you want to achieve. The physical meaning of the values in matrix A is not important, but the relation between its values and the posted outputs.
stelios loizidis
on 1 Jun 2019
Rik
on 1 Jun 2019
The meaning of the values is not important. Please explain how you derive av from A. Then explain what values you want to retrieve based on index.
stelios loizidis
on 2 Jun 2019
Rik
on 2 Jun 2019
Please show the code you're using to create the av vector. Also show a small example of what values from A you want based on the index vector.
Jan
on 3 Jun 2019
@stelios: We have a severe communication problem in this thread. Although you do explain a lot, the provided information are not useful in any way to understand, which problem you have. I do not understand, what this mean:
What locations have non-zero averages (index matrix), I want Matlab to go to matrix A to find out what the ratings I made for that particular visitor I originally selected in these locations with the non-zero average.
Restart the description of the problem from scratch. Until now, the relation between A and av have not been explained clearly. The text must not contain the words "visitors" and "ratings", because all you are talking of are numbers. Try to split the problem into parts, such that you can explain it in short sentences. Avoid expressions like "Matlab go to matrix A", because Matlab is a programming language and it will not "go" anywhere. Prefer "Find the values of A, which satisfy the condition: ..."
stelios loizidis
on 3 Jun 2019
Jan
on 4 Jun 2019
@stelios: Okay, this is a good direction. I'm still not sure, what you are asking for. I try to translate this to Matlab. Actually you have this code already, so it might have been easier, if you post it:
A = rand(1140, 837);
sA = size(A);
% "I choose a column":
c = randi(sA(2), 1);
% " I randomly zeroshed some values from this column":
A(rand(sA(1), 1) > 0.9, c) = 0;
% " calculated the difference that occurs with the other columns in matrix A"
B = A(:, (1:sA(2)) ~= c) - A(:, c);
% "chose the columns that had the smallest difference"
% ??? How is "smallest difference" defined between a set of vectors?
smallest = ???
av = mean(B(:, smallest), 2);
% " In matrix index there are the rows to which my averagrs belong
% and I have all sorts of things in the end."
Here I'm completely lost. And the last sentence is not clear to me also:
% for every average>0 to see what values the original column
% I have selected from matrix A
I guess, all you need is to find some indices, perhaps related to smallest or to the columns of A, which are not the chosen column: (1:sA(2)) ~= c. Maybe it is just one line of code.
stelios loizidis
on 4 Jun 2019
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!