You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
finding data from a big matrix
1 view (last 30 days)
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
stelios loizidis
on 30 May 2019
For example:
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]
stelios loizidis
on 30 May 2019
In the xample above we have matrixs with data. I have matrix A in which the rows symbolize some locations while the columns of some visitors. The matrix A is the averages that visitors put in the locstions that went, while in matrix index are corresponding locations of the averages of matrix av. What I want is Matlab to get the locations in the index matrix and which locations have no average of zero (matrix av) and go to matrix A to find out what the visitor has rated for these specific loactions.
stelios loizidis
on 30 May 2019
I am sorry matrix av is the averages thata visitors put in the locations that went. I wrote it wrong in the top description.
stelios loizidis
on 31 May 2019
The matrix A contains the ratings that visitors put in each location they visited (e.g: in the example above I wrote A(2,4)=4: this means that visitors 4 put a rating of 4 at location 4, e.g: A(3,6)=5: this means that visitor 6 put a rating of 5 at location 3 etc).
In matrix av there are simply average ratings that visitoers have placed in the locations they visited.
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
Sorry, you are right this location instead of 4. A far as the code you refer to my darova suggested it. As far as the data I mention in the above example is accidental.
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
First of all I apologize for having trouble. What I am trying to do is automate some calculations. That is, as I told you initially, I have a matrix A size 1140X837. Also his columns symbolize visitors and the rows the locations and this matrix contains the ratings I put on a visitor to the location that went. Then I chose a random visitor from matrix A and then at the end of the code I wrote, I calculate the average of the ratings that other visitors have (matrix av) and which locations thee averages belong to (matrix index). The last thing I do is find as many locations as their average is not zero to go to matrix A to find out what the random visitor I orginally chose in those locations that have a non-zero average and I want to count it Matlab.
stelios loizidis
on 2 Jun 2019
The av matrix contains the average ratings of the 836 visitors except for a particular visitor I chose initially. I averaged these averages based on the rankings that visitors put in each location they went, and also these ratings come from matrix A. This creates the av matrix. What I am trying to do is automate the following: 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.
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
I have a big matrix A (1140X837) in which there are some values. I first chose a column from this matrix A, and I made some calcualtions. In particular, I randomly zeroshed some values from this column and calculated the difference that occurs with the other columns in matrix A. Then, I chose the columns that had the smallest difference and for each one I calculated its average and so I created the matrix av. Matrix av contains the average of the columns that had the smallest difference with the column I chose initially. In matrix index there are the rows to which my averagrs belong and I have all sorts of things in the end. What I am trying to do is for every average>0 to see what values the original column I have selected from matrix A.
This is the best description I could give you.
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
I try to resolve the problem I have and i think I am close. Thanks for your interest.
Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)