How do I create a new matrix using other matrix data?

조회 수: 1 (최근 30일)
stelios loizidis
stelios loizidis 2019년 5월 4일
Hellow,
The following code reads as follows: First, a matrix is imported from the reviewMatrix.mat file. ReviewMatrix ia a matrix 834X1140. The rows of this matrix are considered to be some locations (834), while the columns are considered to be visitors (1140) and in addition the reviewMatrix contains scores scored by visitors in the locations they visited. After these scores I replaced them with "1" and created the supReviewMartix matrix. Then, I chose a random visitor (e.g 305) and created the matrices shown in the code below. Then I used the command sort and in the end because I want to find the %first reviewer I did the following (note: the point with %first reviewer I do it manually, while the rest I count ia all matrices).
Now I have the following problems: 1) I have to make a new matrix supReviewMatrix. This new matrix will result from the original matrix supReviewMatrix but from each column I have to randomly remove some items with the following restrictions:If a visitor (column) went to 1 or 2 or 3 or 4 locations and put a score stay as they are, if he went 5 or 6 or 7 or 8 locations to be removed 3 random scores he put and if he went to 9 or more to remove 4 random scoring. After the rest of the process will be the same as before. 2)How do I automate the point (first_clo_visitor=I(visitor_number-9)) with %first reviewer to be done for all the cases because as I do it manually.
These two problems should be resolved without using for loop because the data is enough and with for loop Matlab is delayed until it producrs a result.
Code:
%inser data
load("reviewMatrix.mat")
supReviewMatrix=(ReviewMatrix>0)% places zero or one (in matrix reviewMatrix)
% where a visitor scores
%matrix size
matrixsizes = size(ReviewMatrix)
locations_number=matrixsizes(1)%locations are the rows
visitors_number=matrixsizes(2) % visitors are the columns
%manually select a visitor at random
visitor=305
visitor_col=supReviewMatrix(:,visitor)
visitortmpMatrix=(visitor_col*ones(1,visitor_number)).*supReviewMatrix
visitor_sim=sum(visitortmpMatrix)
%sort visitor_sim, Y shows the number of common locations in ascending order
%while the I shows in the visitor belongs the number of common
%locations present in Y
[Y,I]=sort (visitor_sim)
%first reviewer
first_clo_visitor=I(visitors_number-9)
visitors_scores=ReviewMatrix(:,visitor)
clo_visitor_scores=ReviewMatrix(:,first_clo_visitor)
clo_scores=abs(visitors_scores-clo_visitor_scores).*supReviewMatrix(:,visitor).*supReviewMartix(:,first_clo_visitor)
over_clo=sum(clo_scores)

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by