Data Processing of a Matrix

1 次查看(过去 30 天)
stelios loizidis
stelios loizidis 2019-5-13
Hellow,
I have stuck to a point of the code I am writing. In summary, there is a matrix (ReviewMatrix) that carries data from an excel file. I then try to remove some random data from this matrix and create a new matrix (NewReviewMatrix) What I am having trouble is how to replace the SupReviewTable with the new matrix (NewReviewMatrix) so I can calculate VisitorsSim. Below is the code I wrote.
load("ReMatrix")
SupReviewMatrix=(ReviewMatrix>0)
A=sum(SupReviewMatrix)
th=5 %threshold
for i=1:1000
if A(i)>th
ReductionRatings=th-A(i) % scores decucted visitors who went to several locations
while (ReductionRatings>0)
Location=randi(800)
if (SupReviewMatrix(location,i)>0) % positive review and will remove it
SupReviewMatrix(location,i)=0
A(i)=A(i)-1
ReductionRatings=ReductionRatings-1
end
end
end
end
sizeMatrix=size(ReviewMatrix)
visitor_num=sizeMatrix(2)
location_num=sizeMatrix(1)
visitor=400
visitor_column=SupReviewMatrix(:,visitor)
Visitor_Matrix=(visitor_column*ones(1,visitor_num)).*SupReviewMatrix
VisitorsSim=sum(Visitor_Matrix)
  7 个评论
Bob Thompson
Bob Thompson 2019-5-13
Ok, I have a better handle on what you're asking now.
If you aren't sure if your matrix is correct or not, I would suggest making a new matrix, rather than modifying the old one. To do this just change the variable names inside the loop.
If you are looking to calculate the visitor_column, visitor_matrix, and visitorsim with the new matrix each time, then just move the calculations inside the loop. Just be sure and index your results, or you will only see the final result.
As I mentioned earlier, your loop is not currently making any changes because your logic is coming back false every time. Make sure you update that.
stelios loizidis
stelios loizidis 2019-5-14
Because I was confused, how to fix the loop and the index of the matrices because I want to figure out I will put them in the loop as suggested to me and I also want to see all the values not only the final value.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by