Data Processing of a Matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Bob Thompson
el 13 de Mayo de 2019
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.
Respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!